From: Chris Duncan Date: Sun, 8 Dec 2024 03:29:58 +0000 (-0800) Subject: Group up test runner tests. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=5730284e9d585d66e97324e90d2f3f3e86089f4c;p=libnemo.git Group up test runner tests. --- 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 => {