From 39582f9e4877c7a23178e7062ab76dd93c66a937 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 9 Aug 2021 02:12:35 +0100 Subject: [PATCH] Tests: Enable all test suites in CI 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 https://github.com/qunitjs/qunit/pull/1319. * Add test/webWorker.html. Ref https://github.com/qunitjs/qunit/pull/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 78bda44791. 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 https://github.com/qunitjs/qunit/issues/1511. --- Gruntfile.js | 78 +++++++++++++++----------------- test/each.html | 14 ------ test/headless.html | 20 ++++++--- test/index.html | 3 +- test/performance-mark.js | 2 +- test/sandboxed-iframe.js | 9 ++++ test/stack-errors.html | 13 ------ test/stack-errors.js | 96 ---------------------------------------- test/webWorker-worker.js | 10 ++++- test/webWorker.js | 28 +++++------- 10 files changed, 79 insertions(+), 194 deletions(-) delete mode 100644 test/each.html delete mode 100644 test/stack-errors.html delete mode 100644 test/stack-errors.js diff --git a/Gruntfile.js b/Gruntfile.js index 8791d831e..e9b821324 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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", @@ -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", ] } } ); diff --git a/test/each.html b/test/each.html deleted file mode 100644 index ef0385cc9..000000000 --- a/test/each.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - QUnit.test.each Suite - - - - - -
-
test markup
- - diff --git a/test/headless.html b/test/headless.html index f44ad10c0..5e1ce6470 100644 --- a/test/headless.html +++ b/test/headless.html @@ -2,27 +2,33 @@ - QUnit Headless Test Suite + Headless HTML Reporter +
test markup
diff --git a/test/index.html b/test/index.html index 8d8816ac3..86e97ce2d 100644 --- a/test/index.html +++ b/test/index.html @@ -21,8 +21,9 @@ - + + diff --git a/test/performance-mark.js b/test/performance-mark.js index a7d0d7478..22905a329 100644 --- a/test/performance-mark.js +++ b/test/performance-mark.js @@ -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 ); diff --git a/test/sandboxed-iframe.js b/test/sandboxed-iframe.js index 51b796fb3..3ba60339b 100644 --- a/test/sandboxed-iframe.js +++ b/test/sandboxed-iframe.js @@ -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; diff --git a/test/stack-errors.html b/test/stack-errors.html deleted file mode 100644 index 9534b0037..000000000 --- a/test/stack-errors.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - QUnit Main Test Suite - - - - - -
- - diff --git a/test/stack-errors.js b/test/stack-errors.js deleted file mode 100644 index 6d23f34aa..000000000 --- a/test/stack-errors.js +++ /dev/null @@ -1,96 +0,0 @@ -/* global polluteGlobal:true */ -/* exported polluteGlobal */ -/* eslint qunit/no-reassign-log-callbacks:off */ - -// No pollution -QUnit.test( "globals", function( assert ) { - QUnit.config.noglobals = true; - polluteGlobal = 1; - assert.expect( 0 ); -} ); - -// Failing test -QUnit.test( "failing", function( assert ) { - assert.equal( "foo", "bar" ); -} ); - -// No assertions fail -QUnit.test( "no assertions", function() { } ); - -// Start error inside of a test context -QUnit.test( "QUnit.start()", function() { - QUnit.start(); // eslint-disable-line qunit/no-qunit-start-in-tests -} ); - -// Died on test -QUnit.test( "dies on test", function() { - throw new Error( "foo" ); -} ); - -// Test beforeEach die -QUnit.module( "beforeEach fail", { - beforeEach: function() { - throw new Error( "foo" ); - } -} ); -QUnit.test( "module fails", function() { } ); - -// Test afterEach die -QUnit.module( "afterEach fail", { - afterEach: function() { - throw new Error( "bar" ); - } -} ); -QUnit.test( "module fails", function() { } ); - -// Test assert.async post-resolution assertions fail -QUnit.module( "assertions fail after assert.async flows are resolved" ); - -QUnit.test( "assert.ok", function( assert ) { - assert.async()(); - assert.ok( true, "This assertion should pass but have a failure logged before it" ); -} ); - -QUnit.test( "assert.equal", function( assert ) { - assert.async()(); - assert.equal( 1, 1, "This assertion should pass but have a failure logged before it" ); -} ); - -QUnit.test( "assert.throws", function( assert ) { - assert.async()(); - assert.throws( function() { - throw new Error( "foo" ); - }, "This assertion should pass but have a failure logged before it" ); -} ); - -QUnit.module( "globals" ); - -// Start error outside of a test context -setTimeout( function() { - QUnit.start(); -}, 0 ); - -// Test pushFailure outside of a test context -setTimeout( function() { - QUnit.pushFailure( true ); -}, 0 ); - -// Assertion outside of a test context -setTimeout( function() { - QUnit.ok( true ); -}, 0 ); - -// Trigger window.onerror -setTimeout( function() { - throw new Error( "foo" ); -}, 0 ); - -// DEPRECATED: To be removed in QUnit 2.0.0 -// Trigger warnings by replacing the logging callbacks -QUnit.begin = function() {}; -QUnit.done = function() {}; -QUnit.log = function() {}; -QUnit.testStart = function() {}; -QUnit.testDone = function() {}; -QUnit.moduleStart = function() {}; -QUnit.moduleDone = function() {}; diff --git a/test/webWorker-worker.js b/test/webWorker-worker.js index 5ddd3addb..ddb38fa3a 100644 --- a/test/webWorker-worker.js +++ b/test/webWorker-worker.js @@ -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 ) => { diff --git a/test/webWorker.js b/test/webWorker.js index af65a638b..061df1d6c 100644 --- a/test/webWorker.js +++ b/test/webWorker.js @@ -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(); + }; +} );