From 5730284e9d585d66e97324e90d2f3f3e86089f4c Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sat, 7 Dec 2024 19:29:58 -0800 Subject: [PATCH] Group up test runner tests. --- GLOBALS.mjs | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/GLOBALS.mjs b/GLOBALS.mjs index 37c6c5f..4d269f2 100644 --- a/GLOBALS.mjs +++ b/GLOBALS.mjs @@ -31,35 +31,36 @@ function pass (...args) { /** * Who watches the watchers? */ -console.assert(failures.length === 0) -console.assert(passes.length === 0) +await suite('TEST RUNNER CHECK', async () => { + console.assert(failures.length === 0) + console.assert(passes.length === 0) -await test('promise should pass', new Promise(resolve => { resolve('') })) -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[0])) === true, `good promise not logged`) + await test('promise should pass', new Promise(resolve => { resolve('') })) + 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[0])) === true, `good promise not logged`) -await test('promise should fail', new Promise((resolve, reject) => { reject('FAILURE EXPECTED HERE') })) -console.assert(failures.some(call => /.*promise should fail.*/.test(call[0])) === true, `bad promise not errored`) -console.assert(passes.some(call => /.*promise should fail.*/.test(call[0])) === false, 'bad promise logged') + await test('promise should fail', new Promise((resolve, reject) => { reject('FAILURE EXPECTED HERE') })) + console.assert(failures.some(call => /.*promise should fail.*/.test(call[0])) === true, `bad promise not errored`) + console.assert(passes.some(call => /.*promise should fail.*/.test(call[0])) === false, 'bad promise logged') -await test('async should pass', async () => { }) -console.assert(failures.some(call => /.*async should pass.*/.test(call[0])) === false, 'good async errored') -console.assert(passes.some(call => /.*async should pass.*/.test(call[0])) === true, 'good async not logged') + await test('async should pass', async () => { }) + console.assert(failures.some(call => /.*async should pass.*/.test(call[0])) === false, 'good async errored') + console.assert(passes.some(call => /.*async should pass.*/.test(call[0])) === 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[0])) === true, 'bad async not errored') -console.assert(passes.some(call => /.*async should fail.*/.test(call[0])) === false, 'bad async logged') + await test('async should fail', async () => { throw new Error('FAILURE EXPECTED HERE') }) + console.assert(failures.some(call => /.*async should fail.*/.test(call[0])) === true, 'bad async not errored') + console.assert(passes.some(call => /.*async should fail.*/.test(call[0])) === false, 'bad async logged') -await test('function should pass', () => { }) -console.assert(failures.some(call => /.*function should pass.*/.test(call[0])) === false, 'good function errored') -console.assert(passes.some(call => /.*function should pass.*/.test(call[0])) === true, 'good function not logged') + await test('function should pass', () => { }) + console.assert(failures.some(call => /.*function should pass.*/.test(call[0])) === false, 'good function errored') + console.assert(passes.some(call => /.*function should pass.*/.test(call[0])) === true, 'good function not logged') -await test('function should fail', 'FAILURE EXPECTED HERE') -console.assert(failures.some(call => /.*function should fail.*/.test(call[0])) === true, 'bad function not errored') -console.assert(passes.some(call => /.*function should fail.*/.test(call[0])) === false, 'bad function logged') + await test('function should fail', 'FAILURE EXPECTED HERE') + console.assert(failures.some(call => /.*function should fail.*/.test(call[0])) === true, 'bad function not errored') + console.assert(passes.some(call => /.*function should fail.*/.test(call[0])) === false, 'bad function logged') -console.log(`> TEST RUNNER CHECK DONE <`) -console.log(` `) + console.log(`%cTEST RUNNER CHECK DONE`, 'font-weight:bold') +}) export function skip (name) { return new Promise(resolve => { -- 2.34.1