diff --git a/scripts/test-runner.ts b/scripts/test-runner.ts index d833ab6f..85583b92 100644 --- a/scripts/test-runner.ts +++ b/scripts/test-runner.ts @@ -26,21 +26,21 @@ declare global { } } interface TestDisplay { - [key: string]: TestDisplay | StrippedTestResults + [key: string]: TestDisplay | StrippedTestResults; } const colors = { reset: "\x1b[0m", green: "\x1b[32m", red: "\x1b[31m", -} +}; async function runTests() { const puppeteerArgs: string[] = [ `--load-extension=${path.resolve(__dirname, "../test/chrome")}`, // for CI "--no-sandbox", - "--lang=en-US,en" + "--lang=en-US,en", ]; const browser = await puppeteer.launch({ @@ -48,7 +48,6 @@ async function runTests() { args: puppeteerArgs, // chrome extensions don't work in headless headless: false, - executablePath: process.env.PUPPETEER_EXEC_PATH, }); const mochaPage = await browser.newPage(); await mochaPage.goto( @@ -57,27 +56,29 @@ async function runTests() { // by setting this env var, console logging works for both components and testing if (process.env.ENABLE_CONSOLE) { - mochaPage.on("console", consoleMessage => console.log(consoleMessage.text())); + mochaPage.on("console", (consoleMessage) => + console.log(consoleMessage.text()) + ); } const results: { testResults: MochaTestResults; } = await mochaPage.evaluate(() => { - return new Promise((resolve: (value: { - testResults: MochaTestResults; - }) => void) => { - window.addEventListener("testsComplete", () => { - resolve({ - testResults: window.__mocha_test_results__, + return new Promise( + (resolve: (value: { testResults: MochaTestResults }) => void) => { + window.addEventListener("testsComplete", () => { + resolve({ + testResults: window.__mocha_test_results__, + }); }); - }); - if (window.__mocha_test_results__.completed) { - resolve({ - testResults: window.__mocha_test_results__, - }); + if (window.__mocha_test_results__.completed) { + resolve({ + testResults: window.__mocha_test_results__, + }); + } } - }); + ); }); let failedTest = false; @@ -86,7 +87,7 @@ async function runTests() { for (const test of results.testResults.tests) { let tmp: TestDisplay = {}; test.path.reduce((acc, current, index) => { - return acc[current] = test.path.length - 1 === index ? test : {} + return (acc[current] = test.path.length - 1 === index ? test : {}); }, tmp); display = merge(display, tmp); } @@ -103,7 +104,7 @@ async function runTests() { case "failed": console.log(`${colors.red}✗ ${test.title}${colors.reset}`); if (test.err) { - console.log(test.err) + console.log(test.err); } failedTest = true; break; @@ -112,18 +113,18 @@ async function runTests() { break; } } else { - console.log(key) + console.log(key); console.group(); printDisplayTests(display[key]); } } console.groupEnd(); - } + }; printDisplayTests(display); process.exit(failedTest ? 1 : 0); } -runTests().catch(e => { +runTests().catch((e) => { console.error(e); process.exit(1); });