🌐 AI搜索 & 代理 主页
Skip to content

Commit ecd8dde

Browse files
Krinkletimmywil
authored andcommitted
Tests: Add support for running unit tests via grunt with karma
- Update QUnit to 1.23.1 - Remove unused dl#dl from test/index.html - Remove unused map#imgmap from test/index.html - Ensure all urls to data use baseURI - Add the 'grunt karma:main' task - customContextFile & customDebugFile - Add 'npm run jenkins' script Close gh-3744 Fixes gh-1999
1 parent e84d3bc commit ecd8dde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3399
-2692
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ node_js:
55
- "6"
66
- "8"
77
- "9"
8+
addons:
9+
chrome: stable

Gruntfile.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,88 @@ module.exports = function( grunt ) {
147147
"tween"
148148
]
149149
},
150+
karma: {
151+
options: {
152+
customContextFile: "test/karma.context.html",
153+
customDebugFile: "test/karma.debug.html",
154+
frameworks: [ "qunit" ],
155+
middleware: [ "mockserver" ],
156+
plugins: [
157+
"karma-*",
158+
{
159+
"middleware:mockserver": [
160+
"factory",
161+
require( "./test/middleware-mockserver.js" )
162+
]
163+
}
164+
],
165+
files: [
166+
"test/data/jquery-1.9.1.js",
167+
"external/qunit-assert-step/qunit-assert-step.js",
168+
"external/sinon/sinon.js",
169+
"external/npo/npo.js",
170+
"external/requirejs/require.js",
171+
"test/data/testinit.js",
172+
173+
"dist/jquery.min.js",
174+
175+
// Replacement for testinit.js#loadTests()
176+
"test/data/testrunner.js",
177+
"test/unit/basic.js",
178+
"test/unit/core.js",
179+
"test/unit/callbacks.js",
180+
"test/unit/deferred.js",
181+
"test/unit/deprecated.js",
182+
"test/unit/support.js",
183+
"test/unit/data.js",
184+
"test/unit/queue.js",
185+
"test/unit/attributes.js",
186+
"test/unit/event.js",
187+
"test/unit/selector.js",
188+
"test/unit/traversing.js",
189+
"test/unit/manipulation.js",
190+
"test/unit/wrap.js",
191+
"test/unit/css.js",
192+
"test/unit/serialize.js",
193+
"test/unit/ajax.js",
194+
"test/unit/effects.js",
195+
"test/unit/offset.js",
196+
"test/unit/dimensions.js",
197+
"test/unit/animation.js",
198+
"test/unit/tween.js",
199+
"test/unit/ready.js",
200+
201+
{ pattern: "dist/jquery.js", included: false, served: true },
202+
{ pattern: "dist/*.map", included: false, served: true },
203+
{ pattern: "external/qunit/qunit.css", included: false, served: true },
204+
{
205+
pattern: "test/**/*.@(js|css|jpg|html|xml)",
206+
included: false,
207+
served: true
208+
}
209+
],
210+
reporters: [ "dots" ],
211+
autoWatch: false,
212+
concurrency: 3,
213+
captureTimeout: 20 * 1000,
214+
215+
// To debug tests with Karma:
216+
// - Run 'grunt karma:chrome' or 'grunt karma:firefox'
217+
// (any karma subtask that has singleRun=false)
218+
// - Press "Debug" in the opened browser window.
219+
singleRun: false
220+
},
221+
main: {
222+
browsers: [ "ChromeHeadless" ],
223+
singleRun: true
224+
},
225+
chrome: {
226+
browsers: [ "Chrome" ]
227+
},
228+
firefox: {
229+
browsers: [ "Firefox" ]
230+
}
231+
},
150232
watch: {
151233
files: [ "<%= eslint.dev.src %>" ],
152234
tasks: [ "dev" ]
@@ -222,6 +304,7 @@ module.exports = function( grunt ) {
222304
"newer:uglify",
223305
"remove_map_comment",
224306
"dist:*",
307+
"qunit_fixture",
225308
"compare_size"
226309
] );
227310

@@ -231,6 +314,7 @@ module.exports = function( grunt ) {
231314
"uglify",
232315
"remove_map_comment",
233316
"dist:*",
317+
"qunit_fixture",
234318
"eslint:dist",
235319
"test:fast",
236320
"compare_size"

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,20 +323,20 @@ fireNative( jQuery("#elem")[0], "click" );
323323
### Add random number to url to stop caching ###
324324

325325
```js
326-
url( "some/url.php" );
326+
url( "some/url" );
327327
```
328328

329329
Example:
330330

331331
```js
332-
url("data/test.html");
332+
url("index.html");
333333

334-
=> "data/test.html?10538358428943"
334+
=> "data/index.html?10538358428943"
335335

336336

337-
url("data/test.php?foo=bar");
337+
url("mock.php?foo=bar");
338338

339-
=> "data/test.php?foo=bar&10538358345554"
339+
=> "data/mock.php?foo=bar&10538358345554"
340340
```
341341

342342

build/tasks/qunit_fixture.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var fs = require( "fs" );
2+
3+
module.exports = function( grunt ) {
4+
grunt.registerTask( "qunit_fixture", function() {
5+
var dest = "./test/data/qunit-fixture.js";
6+
fs.writeFileSync(
7+
dest,
8+
"// Generated by build/tasks/qunit_fixture.js\n" +
9+
"QUnit.config.fixture = " +
10+
JSON.stringify(
11+
fs.readFileSync(
12+
"./test/data/qunit-fixture.html",
13+
"utf8"
14+
).toString()
15+
) +
16+
";\n" +
17+
"// Compat with QUnit 1.x:\n" +
18+
"document.getElementById( \"qunit-fixture\" ).innerHTML = QUnit.config.fixture;\n"
19+
);
20+
grunt.log.ok( "Updated " + dest + "." );
21+
} );
22+
};

external/qunit/qunit.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*!
2-
* QUnit 1.20.0
3-
* http://qunitjs.com/
2+
* QUnit 1.23.1
3+
* https://qunitjs.com/
44
*
55
* Copyright jQuery Foundation and other contributors
66
* Released under the MIT license
7-
* http://jquery.org/license
7+
* https://jquery.org/license
88
*
9-
* Date: 2015-10-27T17:53Z
9+
* Date: 2016-04-12T17:29Z
1010
*/
1111

1212
/** Font Family and Sizes */
@@ -120,6 +120,10 @@
120120
display: list-item;
121121
}
122122

123+
#qunit-tests.hidepass {
124+
position: relative;
125+
}
126+
123127
#qunit-tests.hidepass li.running,
124128
#qunit-tests.hidepass li.pass {
125129
visibility: hidden;

0 commit comments

Comments
 (0)