Skip to content

Commit

Permalink
Tests: Enable all test suites in CI
Browse files Browse the repository at this point in the history
Several of the HTML test suites were previously omitted from CI,
as they either couldn't pass on PhantomJS, or were simply forgotten.

* Add test/headless.html. Also updated to use `QUnit.on()`, and to hide
  debug messages when run in CI to avoid adding this noise.
* Add test/module-filter.html
* Add test/performance-mark.html. Ref qunitjs#1319.
* Add test/webWorker.html. Ref qunitjs#1171.
* Remove test/each.html. Duplicate of test/index.html.
* Remove test/stack-errors.html. Redundant with other tests for "noglobals"
  and "onUncaughtError" outside test context etc.
* Improve test/sandboxed-iframe.html, which was passing CI
  but failing manually, due to undefined `__grunt_contrib_qunit__`. We
  now define a fallback locally to ease debugging.

Added to test-on-node: test/module-skip.js, test/module-todo.js. These
were disabled due to use of hacky `QUnit.done()`, but that was recently
fixed with 78bda44.

Also add various main tests to test/webWorker.js, which had not been
updated in a while. The next commit will add a meta CLI test that
ensures that these are all in sync to avoid staleness in the future.

Ref qunitjs#1511.
  • Loading branch information
Krinkle committed Aug 9, 2021
1 parent b134792 commit 39582f9
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 194 deletions.
78 changes: 35 additions & 43 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,47 +70,51 @@ module.exports = function( grunt ) {
],
urls: [
"test/index.html",

"test/amd.html",
"test/autostart.html",
"test/startError.html",
"test/reorder.html",
"test/reorderError1.html",
"test/reorderError2.html",
"test/events-filters.html",
"test/events-in-test.html",
"test/headless.html",
"test/logs.html",
"test/amd.html",
"test/reporter-html/legacy-markup.html",
"test/reporter-html/no-qunit-element.html",
"test/reporter-html/single-testid.html",
"test/reporter-html/window-onerror.html",
"test/reporter-html/window-onerror-preexisting-handler.html",
"test/reporter-html/xhtml-escape-details-source.xhtml",
"test/reporter-html/xhtml-single-testid.xhtml",
"test/reporter-urlparams.html",
"test/reporter-urlparams-hidepassed.html",
"test/module-filter.html",
"test/module-skip.html",
"test/module-todo.html",
"test/moduleId.html",
"test/seed.html",
"test/only-each.html",
"test/overload.html",
"test/performance-mark.html",
"test/preconfigured.html",
"test/regex-filter.html",
"test/regex-exclude-filter.html",
"test/regex-filter.html",
"test/reorder.html",
"test/reorderError1.html",
"test/reorderError2.html",
"test/reporter-urlparams-hidepassed.html",
"test/reporter-urlparams.html",
"test/sandboxed-iframe.html",
"test/seed.html",
"test/startError.html",
"test/string-filter.html",
"test/module-skip.html",
"test/module-todo.html",
"test/only-each.html",
"test/webWorker.html",

"test/reporter-html/legacy-markup.html",
"test/reporter-html/no-qunit-element.html",
"test/reporter-html/single-testid.html",
"test/reporter-html/window-onerror-preexisting-handler.html",
"test/reporter-html/window-onerror.html",
"test/reporter-html/xhtml-escape-details-source.xhtml",
"test/reporter-html/xhtml-single-testid.xhtml"

// ensure this is last - it has the potential to drool
// and omit subsequent tests during coverage runs
"test/sandboxed-iframe.html"
].map( file => `http://localhost:${connectPort}/${file}` )
}
}
},

// Sync with test/index.html and test/mozjs.js
"test-on-node": {
files: [
"test/logs.js",

// Sync with test/index.html and test/mozjs.js
"test/main/test.js",
"test/main/each.js",
"test/main/assert.js",
Expand All @@ -125,32 +129,20 @@ module.exports = function( grunt ) {
"test/main/utilities.js",
"test/main/onError.js",
"test/main/onUncaughtException.js",
"test/events-in-test.js",
"test/setTimeout.js",

// Sync with test/*.html files that also make sense for Node.js
"test/events-in-test.js",
"test/logs.js",
"test/module-skip.js",
"test/module-todo.js",

"test/node/storage-1.js",
"test/node/storage-2.js",

"test/cli/fixtures/only/test.js",
"test/cli/fixtures/only/module.js",
"test/cli/fixtures/only/module-flat.js",

"test/es2018/async-functions.js",
"test/es2018/rejects.js",
"test/es2018/throws.js"

// FIXME: These tests use an ugly hack that re-opens
// an already finished test run. This only works reliably
// via the HTML Reporter thanks to some delays in the bridge.
// These tests are about reporting, not about functional
// behaviour. They would be best run either as reflection on the
// DOM in an HTML Reporter test, or from the CLI by asserting
// TAP output. I suggest we do the latter, and then remove them
// from here.
//
// Ref https://github.com/qunitjs/qunit/issues/1511
//
// "test/module-skip.js",
// "test/module-todo.js",
]
}
} );
Expand Down
14 changes: 0 additions & 14 deletions test/each.html

This file was deleted.

20 changes: 13 additions & 7 deletions test/headless.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@
<html>
<head>
<meta charset="UTF-8">
<title>QUnit Headless Test Suite</title>
<title>Headless HTML Reporter</title>
<link rel="stylesheet" href="../qunit/qunit.css">
<script src="../qunit/qunit.js"></script>
<script src="main/test.js"></script>
<script src="main/deepEqual.js"></script>
<script>
( function() {
function createCallback( logType ) {
QUnit[ logType ]( function() {
console.log( logType, arguments );
function createCallback( eventName ) {
QUnit.on( eventName, function( eventData ) {
console.log( eventName, eventData );
} );
}

var logs = [ "begin", "testStart", "testDone", "log", "moduleStart", "moduleDone", "done" ];
for ( var i = 0; i < logs.length; i++ ) {
createCallback( logs[ i ] );
// For debugging
if ( self.__grunt_contrib_qunit__ === undefined ) {
var logs = [ "runStart", "testStart", "testEnd", "runEnd" ];
for ( var i = 0; i < logs.length; i++ ) {
createCallback( logs[ i ] );
}
}
}() );
</script>
</head>
<body>
<!-- There is no div#qunit element, which means there should
not be any default UI on this page.
-->
<div id="qunit-fixture">test markup</div>
</body>
</html>
3 changes: 2 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
<script src="main/onError.js"></script>
<script src="main/onUncaughtException.js"></script>
<script src="setTimeout.js"></script>
<script src="reporter-html/reporter-html.js"></script>

<script src="reporter-html/diff.js"></script>
<script src="reporter-html/reporter-html.js"></script>
<script src="reporter-html/unhandled-rejection.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion test/performance-mark.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
QUnit.module( "urlParams performance mark module", function() {
QUnit.test( "shouldn't fail if performance marks are cleared ", function( assert ) {
QUnit.test( "shouldn't fail if performance marks are cleared", function( assert ) {
performance.clearMarks();

assert.true( true );
Expand Down
9 changes: 9 additions & 0 deletions test/sandboxed-iframe.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
// For debugging
if ( self.__grunt_contrib_qunit__ === undefined ) {
self.__grunt_contrib_qunit__ = function() {
var args = [].slice.call( arguments );
args.unshift( "[grunt-contrib-qunit]" );
console.log.apply( console, args );
};
}

QUnit.module( "QUnit.only", function( hooks ) {
var testsRun = 0;

Expand Down
13 changes: 0 additions & 13 deletions test/stack-errors.html

This file was deleted.

96 changes: 0 additions & 96 deletions test/stack-errors.js

This file was deleted.

10 changes: 8 additions & 2 deletions test/webWorker-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
/* eslint-env es6 */
importScripts(
"../qunit/qunit.js",

"main/test.js",
"main/each.js",
"main/assert.js",
"main/assert/step.js",
"main/assert-step.js",
"main/assert-timeout.js",
"main/async.js",
"main/promise.js",
"main/dump.js",
"main/modules.js",
"main/deepEqual.js",
"main/stack.js"
"main/stack.js",
"main/utilities.js",
"main/onError.js",
"main/onUncaughtException.js"
);

QUnit.on( "runEnd", ( data ) => {
Expand Down
28 changes: 11 additions & 17 deletions test/webWorker.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
( function( window ) {
QUnit.module( "Web Worker" );

QUnit.module( "Runs a QUnit suite in a Web Worker" );
var testMethod = window.Worker ? "test" : "skip";

var testMethod = window.Worker ? "test" : "skip";
QUnit[ testMethod ]( "main tests", function( assert ) {
assert.expect( 1 );
var done = assert.async();
var worker = new Worker( "webWorker-worker.js" );

QUnit[ testMethod ]( "test", function( assert ) {
assert.expect( 1 );
var done = assert.async();
var worker = new Worker( "webWorker-worker.js" );

worker.onmessage = function( event ) {
assert.equal( event.data.status, "passed" );
done();
};
} );

}( ( function() {
return this;
}() ) ) );
worker.onmessage = function( event ) {
assert.equal( event.data.status, "passed", "runEnd.status" );
done();
};
} );

0 comments on commit 39582f9

Please sign in to comment.