diff --git a/scripts/browserTest/index.mjs b/scripts/browserTest/index.mjs index 5c1f550..da3bb0c 100644 --- a/scripts/browserTest/index.mjs +++ b/scripts/browserTest/index.mjs @@ -21,7 +21,7 @@ const ERROR_CODES = { let hasError = false const server = createServer(requestListener({ serve, collectCoverage })) -server.closeAsync = () => new Promise(resolve => server.close(() => resolve())) +server.closeAsync = () => /** @type {Promise} */(new Promise(resolve => server.close(() => resolve()))) /** * @param {{fileName:string, browser:puppeteer.Browser}} param0 diff --git a/scripts/browserTest/mime.mjs b/scripts/browserTest/mime.mjs index d9d9ae6..9e2fa25 100644 --- a/scripts/browserTest/mime.mjs +++ b/scripts/browserTest/mime.mjs @@ -1,3 +1,5 @@ +// @ts-check + import { extname } from 'path' export const mime = fileName => { diff --git a/scripts/browserTest/nyc.mjs b/scripts/browserTest/nyc.mjs index c88c185..a2b8ccb 100644 --- a/scripts/browserTest/nyc.mjs +++ b/scripts/browserTest/nyc.mjs @@ -1,3 +1,5 @@ +// @ts-check + import { spawn } from 'child_process' const isWin = process.platform === 'win32' diff --git a/scripts/browserTest/requestListener.mjs b/scripts/browserTest/requestListener.mjs index dd01d55..b890dee 100644 --- a/scripts/browserTest/requestListener.mjs +++ b/scripts/browserTest/requestListener.mjs @@ -1,7 +1,8 @@ +// @ts-check + import path from 'path' import { mime } from './mime.mjs' import { readFile } from 'fs/promises' -import { spawn } from 'child_process' import { dirname, join } from 'path' import { fileURLToPath } from 'url' import { NYC } from './nyc.mjs' @@ -13,12 +14,12 @@ const testerJS = await readFile(join(__dirname, './tester.js'), { encoding: 'utf export const totalPasses = [0, 0] +/** @type {Array<{text:string, id: number, type?: string}>} */ let _messages = [] + const sendMessages = () => { _messages - .sort((a, b) => { - a.id - b.id - }) + .sort((a, b) => a.id - b.id) .forEach(m => { if (m.type === 'end') { const match = m.text.match(/(\d+)\/(\d+).passing/m) @@ -39,6 +40,7 @@ const sendMessages = () => { _messages = [] } + const queueMessages = message => { _messages.push(message)