Skip to content

Commit

Permalink
Restore test harness on CI
Browse files Browse the repository at this point in the history
The test harness haven't been accurately reporting failures, this
restores it.
  • Loading branch information
chancancode committed Feb 1, 2024
1 parent e813777 commit 5f8ab8c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
44 changes: 25 additions & 19 deletions bin/run-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,31 @@ const browser = await puppeteer.launch({

console.log('[ci] puppeteer launched');

await /** @type {Promise<void>} */ (
// eslint-disable-next-line no-async-promise-executor
new Promise(async (fulfill) => {
const page = await browser.newPage();

page.on('console', (msg) => {
const location = msg.location();
const text = msg.text();

if (location.url?.includes(`/qunit.js`)) {
console.log(text);
} else if (text === `[HARNESS] done`) {
fulfill();
}
});

await page.goto('http://localhost:60173?hidepassed&ci');
})
);
try {
await /** @type {Promise<void>} */ (
new Promise(async (fulfill, reject) => {
const page = await browser.newPage();

page.on('console', (msg) => {
const location = msg.location();
const text = msg.text();

if (location.url?.includes(`/qunit.js`)) {
console.log(text);
} else if (text === `[HARNESS] done`) {
fulfill();
} else if (text === `[HARNESS] fail`) {
reject();
}
});

await page.goto('http://localhost:60173?hidepassed&ci');
})
);
} catch {
await browser.close();
process.exit(1);
}

await browser.close();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ export async function setupQunit() {
qunit.moduleDone(pause);
}

qunit.done(() => {
console.log('[HARNESS] done');
qunit.done(({ failed }) => {
if (failed > 0) {
console.log('[HARNESS] fail');
} else {
console.log('[HARNESS] done');
}
});

return {
Expand Down

0 comments on commit 5f8ab8c

Please sign in to comment.