Skip to content

Commit 533ae1e

Browse files
committed
chore: improve code quality
1 parent dff60a9 commit 533ae1e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/less/test/mocha-playwright/runner.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ function configureViewport(width, height, page) {
129129
function handleConsole(msg) {
130130
const args = msg.args() || [];
131131

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

0 commit comments

Comments
 (0)