Skip to content

Commit 93379d0

Browse files
committed
print manual debug instructions when test fail
1 parent aaa3c3e commit 93379d0

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

test/browser/index.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,32 @@ async function runTestsInBrowser(testModules, browserType) {
111111

112112
withReporter(new EchoRunner(emitter, browserType.toUpperCase()));
113113

114+
// collection failures for console printing
115+
const fails = [];
116+
emitter.on('fail', (test, err) => {
117+
if (err.stack) {
118+
const regex = /(vs\/.*\.test)\.js/;
119+
for (let line of String(err.stack).split('\n')) {
120+
const match = regex.exec(line);
121+
if (match) {
122+
fails.push(match[1]);
123+
break;
124+
}
125+
}
126+
}
127+
});
128+
114129
try {
115130
// @ts-ignore
116131
await page.evaluate(modules => loadAndRun(modules), testModules);
117132
} catch (err) {
118133
console.error(err);
119134
}
120135
await browser.close();
136+
137+
if (fails.length > 0) {
138+
return `to DEBUG, open ${browserType.toUpperCase()} and navigate to ${target.href}?${fails.map(module => `m=${module}`).join('&')}`;
139+
}
121140
}
122141

123142
class EchoRunner extends events.EventEmitter {
@@ -174,7 +193,13 @@ testModules.then(async modules => {
174193

175194
const browserTypes = Array.isArray(argv.browser) ? argv.browser : [argv.browser];
176195
const promises = browserTypes.map(browserType => runTestsInBrowser(modules, browserType));
177-
await Promise.all(promises);
196+
const messages = await Promise.all(promises);
197+
198+
for (let msg of messages) {
199+
if (msg) {
200+
console.log(msg);
201+
}
202+
}
178203

179204
}).catch(err => {
180205
console.error(err);

0 commit comments

Comments
 (0)