Skip to content

Commit

Permalink
Tests: Add support for running unit tests via grunt with karma
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Krinkle authored and timmywil committed Dec 18, 2017
1 parent e84d3bc commit ecd8dde
Show file tree
Hide file tree
Showing 60 changed files with 3,399 additions and 2,692 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ node_js:
- "6" - "6"
- "8" - "8"
- "9" - "9"
addons:
chrome: stable
84 changes: 84 additions & 0 deletions Gruntfile.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -147,6 +147,88 @@ module.exports = function( grunt ) {
"tween" "tween"
] ]
}, },
karma: {
options: {
customContextFile: "test/karma.context.html",
customDebugFile: "test/karma.debug.html",
frameworks: [ "qunit" ],
middleware: [ "mockserver" ],
plugins: [
"karma-*",
{
"middleware:mockserver": [
"factory",
require( "./test/middleware-mockserver.js" )
]
}
],
files: [
"test/data/jquery-1.9.1.js",
"external/qunit-assert-step/qunit-assert-step.js",
"external/sinon/sinon.js",
"external/npo/npo.js",
"external/requirejs/require.js",
"test/data/testinit.js",

"dist/jquery.min.js",

// Replacement for testinit.js#loadTests()
"test/data/testrunner.js",
"test/unit/basic.js",
"test/unit/core.js",
"test/unit/callbacks.js",
"test/unit/deferred.js",
"test/unit/deprecated.js",
"test/unit/support.js",
"test/unit/data.js",
"test/unit/queue.js",
"test/unit/attributes.js",
"test/unit/event.js",
"test/unit/selector.js",
"test/unit/traversing.js",
"test/unit/manipulation.js",
"test/unit/wrap.js",
"test/unit/css.js",
"test/unit/serialize.js",
"test/unit/ajax.js",
"test/unit/effects.js",
"test/unit/offset.js",
"test/unit/dimensions.js",
"test/unit/animation.js",
"test/unit/tween.js",
"test/unit/ready.js",

{ pattern: "dist/jquery.js", included: false, served: true },
{ pattern: "dist/*.map", included: false, served: true },
{ pattern: "external/qunit/qunit.css", included: false, served: true },
{
pattern: "test/**/*.@(js|css|jpg|html|xml)",
included: false,
served: true
}
],
reporters: [ "dots" ],
autoWatch: false,
concurrency: 3,
captureTimeout: 20 * 1000,

// To debug tests with Karma:
// - Run 'grunt karma:chrome' or 'grunt karma:firefox'
// (any karma subtask that has singleRun=false)
// - Press "Debug" in the opened browser window.
singleRun: false
},
main: {
browsers: [ "ChromeHeadless" ],
singleRun: true
},
chrome: {
browsers: [ "Chrome" ]
},
firefox: {
browsers: [ "Firefox" ]
}
},
watch: { watch: {
files: [ "<%= eslint.dev.src %>" ], files: [ "<%= eslint.dev.src %>" ],
tasks: [ "dev" ] tasks: [ "dev" ]
Expand Down Expand Up @@ -222,6 +304,7 @@ module.exports = function( grunt ) {
"newer:uglify", "newer:uglify",
"remove_map_comment", "remove_map_comment",
"dist:*", "dist:*",
"qunit_fixture",
"compare_size" "compare_size"
] ); ] );


Expand All @@ -231,6 +314,7 @@ module.exports = function( grunt ) {
"uglify", "uglify",
"remove_map_comment", "remove_map_comment",
"dist:*", "dist:*",
"qunit_fixture",
"eslint:dist", "eslint:dist",
"test:fast", "test:fast",
"compare_size" "compare_size"
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -323,20 +323,20 @@ fireNative( jQuery("#elem")[0], "click" );
### Add random number to url to stop caching ### ### Add random number to url to stop caching ###


```js ```js
url( "some/url.php" ); url( "some/url" );
``` ```


Example: Example:


```js ```js
url("data/test.html"); url("index.html");


=> "data/test.html?10538358428943" => "data/index.html?10538358428943"




url("data/test.php?foo=bar"); url("mock.php?foo=bar");


=> "data/test.php?foo=bar&10538358345554" => "data/mock.php?foo=bar&10538358345554"
``` ```




Expand Down
22 changes: 22 additions & 0 deletions build/tasks/qunit_fixture.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,22 @@
var fs = require( "fs" );

module.exports = function( grunt ) {
grunt.registerTask( "qunit_fixture", function() {
var dest = "./test/data/qunit-fixture.js";
fs.writeFileSync(
dest,
"// Generated by build/tasks/qunit_fixture.js\n" +
"QUnit.config.fixture = " +
JSON.stringify(
fs.readFileSync(
"./test/data/qunit-fixture.html",
"utf8"
).toString()
) +
";\n" +
"// Compat with QUnit 1.x:\n" +
"document.getElementById( \"qunit-fixture\" ).innerHTML = QUnit.config.fixture;\n"
);
grunt.log.ok( "Updated " + dest + "." );
} );
};
12 changes: 8 additions & 4 deletions external/qunit/qunit.css
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,12 @@
/*! /*!
* QUnit 1.20.0 * QUnit 1.23.1
* http://qunitjs.com/ * https://qunitjs.com/
* *
* Copyright jQuery Foundation and other contributors * Copyright jQuery Foundation and other contributors
* Released under the MIT license * Released under the MIT license
* http://jquery.org/license * https://jquery.org/license
* *
* Date: 2015-10-27T17:53Z * Date: 2016-04-12T17:29Z
*/ */


/** Font Family and Sizes */ /** Font Family and Sizes */
Expand Down Expand Up @@ -120,6 +120,10 @@
display: list-item; display: list-item;
} }


#qunit-tests.hidepass {
position: relative;
}

#qunit-tests.hidepass li.running, #qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass { #qunit-tests.hidepass li.pass {
visibility: hidden; visibility: hidden;
Expand Down
Loading

0 comments on commit ecd8dde

Please sign in to comment.