Skip to content

Commit

Permalink
chore: improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
iChenLei committed Jan 7, 2025
1 parent dff60a9 commit 533ae1e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/less/test/mocha-playwright/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ function configureViewport(width, height, page) {
function handleConsole(msg) {
const args = msg.args() || [];

Promise.all(args.map(a => a.jsonValue().catch(() => '')))
Promise.all(args.map(a => a.jsonValue().catch(error => {
console.warn('Failed to retrieve JSON value from argument:', error);
return '';
})))
.then(args => {
// process stdout stub
let isStdout = args[0] === 'stdout:';
Expand Down Expand Up @@ -192,6 +195,10 @@ exports.runner = function ({ file, reporter, timeout, width, height, args, execu
.then(() => page.waitForFunction(() => window.__mochaResult__, { timeout, polling }))
.then(() => page.evaluate(() => window.__mochaResult__))
.then(result => {
if (!result) {
throw new Error('Mocha results not found after waiting. The tests may not have run correctly.');
}
// Close browser before resolving result
return browser.close().then(() => result);
});
})
Expand Down

0 comments on commit 533ae1e

Please sign in to comment.