]> git.codecow.com Git - libnemo.git/commitdiff
Ensure test runner is done before running tests.
authorChris Duncan <chris@zoso.dev>
Wed, 23 Jul 2025 21:14:25 +0000 (14:14 -0700)
committerChris Duncan <chris@zoso.dev>
Wed, 23 Jul 2025 21:14:25 +0000 (14:14 -0700)
test/test.runner-check.mjs

index abbccbdf3c6722e99b63d5b842f5ab3abf589a6b..547a9efc7d6be66a08babe3976d5952ec8263d2d 100644 (file)
@@ -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')
 }