From 77444e98b11a52a479593993b533e164fecb7fda Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Wed, 23 Jul 2025 14:14:25 -0700 Subject: [PATCH] Ensure test runner is done before running tests. --- test/test.runner-check.mjs | 74 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/test/test.runner-check.mjs b/test/test.runner-check.mjs index abbccbd..547a9ef 100644 --- a/test/test.runner-check.mjs +++ b/test/test.runner-check.mjs @@ -4,43 +4,41 @@ import { failures, isNode, passes, suite, test } from './GLOBALS.mjs' if (!isNode) { - await Promise.all([ - suite('TEST RUNNER CHECK', async () => { - await new Promise(r => setTimeout(r, 0)) - - console.assert(failures.length === 0) - console.assert(passes.length === 0) - - //@ts-expect-error - await test('promise should pass', new Promise(resolve => resolve(null))) - console.assert(failures.some(call => /.*promise should pass.*/.test(call[0])) === false, `good promise errored`) - console.assert(passes.some(call => /.*promise should pass.*/.test(call)) === true, `good promise not logged`) - - //@ts-expect-error - await test('promise should fail', new Promise((resolve, reject) => reject('FAILURE EXPECTED HERE'))) - console.assert(failures.some(call => /.*promise should fail.*/.test(call)) === true, `bad promise not errored`) - console.assert(passes.some(call => /.*promise should fail.*/.test(call)) === false, 'bad promise logged') - - await test('async should pass', async () => {}) - console.assert(failures.some(call => /.*async should pass.*/.test(call)) === false, 'good async errored') - console.assert(passes.some(call => /.*async should pass.*/.test(call)) === true, 'good async not logged') - - await test('async should fail', async () => { throw new Error('FAILURE EXPECTED HERE') }) - console.assert(failures.some(call => /.*async should fail.*/.test(call)) === true, 'bad async not errored') - console.assert(passes.some(call => /.*async should fail.*/.test(call)) === false, 'bad async logged') - - await test('function should pass', () => {}) - console.assert(failures.some(call => /.*function should pass.*/.test(call)) === false, 'good function errored') - console.assert(passes.some(call => /.*function should pass.*/.test(call)) === true, 'good function not logged') - - //@ts-expect-error - await test('function should fail', 'FAILURE EXPECTED HERE') - console.assert(failures.some(call => /.*function should fail.*/.test(call)) === true, 'bad function not errored') - console.assert(passes.some(call => /.*function should fail.*/.test(call)) === false, 'bad function logged') - - failures.splice(0) - passes.splice(0) - }) - ]) + await suite('TEST RUNNER CHECK', async () => { + await new Promise(r => setTimeout(r, 0)) + + console.assert(failures.length === 0) + console.assert(passes.length === 0) + + //@ts-expect-error + await test('promise should pass', new Promise(resolve => resolve(null))) + console.assert(failures.some(call => /.*promise should pass.*/.test(call[0])) === false, `good promise errored`) + console.assert(passes.some(call => /.*promise should pass.*/.test(call)) === true, `good promise not logged`) + + //@ts-expect-error + await test('promise should fail', new Promise((resolve, reject) => reject('FAILURE EXPECTED HERE'))) + console.assert(failures.some(call => /.*promise should fail.*/.test(call)) === true, `bad promise not errored`) + console.assert(passes.some(call => /.*promise should fail.*/.test(call)) === false, 'bad promise logged') + + await test('async should pass', async () => {}) + console.assert(failures.some(call => /.*async should pass.*/.test(call)) === false, 'good async errored') + console.assert(passes.some(call => /.*async should pass.*/.test(call)) === true, 'good async not logged') + + await test('async should fail', async () => { throw new Error('FAILURE EXPECTED HERE') }) + console.assert(failures.some(call => /.*async should fail.*/.test(call)) === true, 'bad async not errored') + console.assert(passes.some(call => /.*async should fail.*/.test(call)) === false, 'bad async logged') + + await test('function should pass', () => {}) + console.assert(failures.some(call => /.*function should pass.*/.test(call)) === false, 'good function errored') + console.assert(passes.some(call => /.*function should pass.*/.test(call)) === true, 'good function not logged') + + //@ts-expect-error + await test('function should fail', 'FAILURE EXPECTED HERE') + console.assert(failures.some(call => /.*function should fail.*/.test(call)) === true, 'bad function not errored') + console.assert(passes.some(call => /.*function should fail.*/.test(call)) === false, 'bad function logged') + + failures.splice(0) + passes.splice(0) + }) console.log(`%cTEST RUNNER CHECK DONE`, 'font-weight:bold') } -- 2.47.3