Permalink
Browse files

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
  • Loading branch information...
Krinkle authored and timmywil committed Aug 1, 2017
1 parent e84d3bc commit ecd8ddea33dc40ae2a57e4340be03faf2ba2f99b
Showing with 3,399 additions and 2,692 deletions.
  1. +2 −0 .travis.yml
  2. +84 −0 Gruntfile.js
  3. +5 −5 README.md
  4. +22 −0 build/tasks/qunit_fixture.js
  5. +8 −4 external/qunit/qunit.css
  6. +2,160 −1,984 external/qunit/qunit.js
  7. +12 −4 package.json
  8. +0 −5 test/data/ajax/content-type.php
  9. +0 −1 test/data/ajax/evalScript.php
  10. +0 −1 test/data/ajax/method.php
  11. +1 −1 test/data/ajax/unreleasedXHR.html
  12. +0 −4 test/data/atom+xml.php
  13. +0 −3 test/data/core/dont_return.php
  14. +1 −1 test/data/core/dynamic_ready.html
  15. +14 −0 test/data/csp.include.html
  16. +0 −1 test/data/echoData.php
  17. +0 −1 test/data/echoQuery.php
  18. +0 −6 test/data/errorWithJSON.php
  19. +0 −5 test/data/errorWithText.php
  20. +0 −24 test/data/etag.php
  21. +1 −1 test/data/event/interactiveReady.html
  22. +1 −1 test/data/event/syncReady.html
  23. +0 −23 test/data/headers.php
  24. +0 −20 test/data/if_modified_since.php
  25. +0 −13 test/data/json.php
  26. +0 −14 test/data/jsonp.php
  27. +0 −4 test/data/longLoadScript.php
  28. +244 −0 test/data/mock.php
  29. +0 −24 test/data/name.php
  30. +0 −5 test/data/nocontent.php
  31. +0 −12 test/data/params_html.php
  32. +237 −0 test/data/qunit-fixture.html
  33. +4 −0 test/data/qunit-fixture.js
  34. +0 −11 test/data/script.php
  35. +0 −5 test/data/statusText.php
  36. +0 −3 test/data/support/csp-clean.php
  37. +0 −3 test/data/support/csp-log.php
  38. +0 −19 test/data/support/csp.php
  39. +2 −2 test/data/{test.html → test.include.html}
  40. +0 −7 test/data/test.php
  41. +0 −3 test/data/testbar.php
  42. +25 −12 test/data/testinit.js
  43. 0 test/data/{text.php → text.txt}
  44. +0 −7 test/data/with_fries_over_jsonp.php
  45. +2 −245 test/index.html
  46. +45 −0 test/karma.context.html
  47. +47 −0 test/karma.debug.html
  48. +284 −0 test/middleware-mockserver.js
  49. +171 −179 test/unit/ajax.js
  50. +2 −2 test/unit/attributes.js
  51. +3 −3 test/unit/basic.js
  52. +3 −3 test/unit/core.js
  53. +2 −3 test/unit/css.js
  54. +1 −1 test/unit/data.js
  55. +1 −1 test/unit/effects.js
  56. +2 −3 test/unit/event.js
  57. +2 −2 test/unit/manipulation.js
  58. +3 −3 test/unit/offset.js
  59. +3 −3 test/unit/support.js
  60. +5 −5 test/unit/traversing.js
@@ -5,3 +5,5 @@ node_js:
- "6"
- "8"
- "9"
addons:
chrome: stable
@@ -147,6 +147,88 @@ module.exports = function( grunt ) {
"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: {
files: [ "<%= eslint.dev.src %>" ],
tasks: [ "dev" ]
@@ -222,6 +304,7 @@ module.exports = function( grunt ) {
"newer:uglify",
"remove_map_comment",
"dist:*",
"qunit_fixture",
"compare_size"
] );
@@ -231,6 +314,7 @@ module.exports = function( grunt ) {
"uglify",
"remove_map_comment",
"dist:*",
"qunit_fixture",
"eslint:dist",
"test:fast",
"compare_size"
@@ -323,20 +323,20 @@ fireNative( jQuery("#elem")[0], "click" );
### Add random number to url to stop caching ###
```js
url( "some/url.php" );
url( "some/url" );
```
Example:
```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"
```
@@ -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 + "." );
} );
};
@@ -1,12 +1,12 @@
/*!
* QUnit 1.20.0
* http://qunitjs.com/
* QUnit 1.23.1
* https://qunitjs.com/
*
* Copyright jQuery Foundation and other contributors
* 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 */
@@ -120,6 +120,10 @@
display: list-item;
}
#qunit-tests.hidepass {
position: relative;
}
#qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass {
visibility: hidden;
Oops, something went wrong.

0 comments on commit ecd8dde

Please sign in to comment.