Comparing version 2.19.1 to 2.19.2
@@ -5,7 +5,7 @@ { | ||
"description": "The powerful, easy-to-use testing framework.", | ||
"version": "2.19.1", | ||
"version": "2.19.2", | ||
"homepage": "https://qunitjs.com", | ||
"author": { | ||
"name": "OpenJS Foundation and other contributors", | ||
"url": "https://github.com/qunitjs/qunit/blob/2.19.1/AUTHORS.txt" | ||
"url": "https://github.com/qunitjs/qunit/blob/2.19.2/AUTHORS.txt" | ||
}, | ||
@@ -58,2 +58,3 @@ "repository": { | ||
"@rollup/plugin-replace": "^3.0.0", | ||
"benchmark": "2.1.4", | ||
"eslint": "7.32.0", | ||
@@ -68,7 +69,7 @@ "eslint-config-semistandard": "^16.0.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"eslint-plugin-promise": "^5.2.0", | ||
"eslint-plugin-qunit": "^6.2.0", | ||
"fixturify": "^2.1.1", | ||
"fuzzysort": "1.2.1", | ||
"grunt": "^1.4.1", | ||
"grunt": "^1.5.2", | ||
"grunt-contrib-connect": "^3.0.0", | ||
@@ -92,2 +93,3 @@ "grunt-contrib-copy": "^1.0.0", | ||
"build-dev": "node build/watch.js", | ||
"benchmark": "npm install --silent --no-audit --prefix test/benchmark/ && node test/benchmark/index-node.js", | ||
"lint": "eslint --cache .", | ||
@@ -94,0 +96,0 @@ "lint-fix": "eslint --cache --fix .", |
@@ -17,3 +17,25 @@ 'use strict'; | ||
let QUnit; | ||
let running = false; | ||
let restartDebounceTimer; | ||
function onUnhandledRejection (reason, _promise) { | ||
QUnit.onUncaughtException(reason); | ||
} | ||
function onUncaughtException (error, _origin) { | ||
QUnit.onUncaughtException(error); | ||
} | ||
function onExit () { | ||
if (running) { | ||
console.error('Error: Process exited before tests finished running'); | ||
const currentTest = QUnit.config.current; | ||
if (currentTest && currentTest.pauses.size > 0) { | ||
const name = currentTest.testName; | ||
console.error('Last test to run (' + name + ') has an async hold. ' + | ||
'Ensure all assert.async() callbacks are invoked and Promises resolve. ' + | ||
'You should also set a standard timeout via QUnit.config.testTimeout.'); | ||
} | ||
} | ||
} | ||
async function run (args, options) { | ||
@@ -109,24 +131,8 @@ // Default to non-zero exit code to avoid false positives | ||
// Handle the unhandled | ||
process.on('unhandledRejection', (reason, _promise) => { | ||
QUnit.onUncaughtException(reason); | ||
}); | ||
process.on('uncaughtException', (error, _origin) => { | ||
QUnit.onUncaughtException(error); | ||
}); | ||
process.on('unhandledRejection', onUnhandledRejection); | ||
process.on('uncaughtException', onUncaughtException); | ||
let running = true; | ||
process.on('exit', function () { | ||
if (running) { | ||
console.error('Error: Process exited before tests finished running'); | ||
running = true; | ||
process.on('exit', onExit); | ||
const currentTest = QUnit.config.current; | ||
if (currentTest && currentTest.pauses.size > 0) { | ||
const name = currentTest.testName; | ||
console.error('Last test to run (' + name + ') has an async hold. ' + | ||
'Ensure all assert.async() callbacks are invoked and Promises resolve. ' + | ||
'You should also set a standard timeout via QUnit.config.testTimeout.'); | ||
} | ||
} | ||
}); | ||
QUnit.on('error', function (_error) { | ||
@@ -151,6 +157,6 @@ // Set exitCode directly, to make sure it is set to fail even if "runEnd" will never be | ||
run.restart = function (args) { | ||
clearTimeout(this._restartDebounceTimer); | ||
run.restart = function restart (args, options) { | ||
clearTimeout(restartDebounceTimer); | ||
this._restartDebounceTimer = setTimeout(() => { | ||
restartDebounceTimer = setTimeout(() => { | ||
changedPendingPurge.forEach(file => delete require.cache[path.resolve(file)]); | ||
@@ -165,8 +171,13 @@ changedPendingPurge.length = 0; | ||
run.abort(() => run.apply(null, args)); | ||
abort(() => run(args, options)); | ||
}, DEBOUNCE_RESTART_LENGTH); | ||
}; | ||
run.abort = function (callback) { | ||
function abort (callback) { | ||
function clearQUnit () { | ||
process.off('unhandledRejection', onUnhandledRejection); | ||
process.off('uncaughtException', onUncaughtException); | ||
process.off('exit', onExit); | ||
running = false; | ||
delete global.QUnit; | ||
@@ -186,7 +197,6 @@ QUnit = null; | ||
} | ||
}; | ||
} | ||
run.watch = function watch (_, options) { | ||
run.watch = function watch (args, options) { | ||
const watch = require('node-watch'); | ||
const args = Array.prototype.slice.call(arguments); | ||
const baseDir = process.cwd(); | ||
@@ -214,3 +224,3 @@ | ||
// Bare minimum delay, we have another debounce in run.restart(). | ||
// Bare minimum delay, we have another debounce in restart(). | ||
delay: DEBOUNCE_WATCH_LENGTH, | ||
@@ -228,7 +238,7 @@ filter: (fullpath, skip) => { | ||
changedPendingPurge.push(fullpath); | ||
run.restart(args); | ||
run.restart(args, options); | ||
}); | ||
watcher.on('ready', () => { | ||
run.apply(null, args); | ||
run(args, options); | ||
}); | ||
@@ -240,3 +250,3 @@ | ||
watcher.close(); | ||
run.abort(() => { | ||
abort(() => { | ||
process.exit(); | ||
@@ -243,0 +253,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
291098
36