Skip to content

Commit

Permalink
[test] Output warnings in the rendered components
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Feb 28, 2021
1 parent 1876502 commit c53e4da
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/regressions/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ async function main() {
// prepare screenshots
await fse.emptyDir(screenshotDir);

let errorMessage;

page.on('console', async (msg) => {
if (msg.args().length > 0 && (msg.type() === 'error' || msg.type() === 'warning')) {
errorMessage = Promise.all(msg.args().map((x) => x.jsonValue()));
}
});

describe('visual regressions', () => {
after(async () => {
await browser.close();
Expand All @@ -77,6 +85,12 @@ async function main() {
await fse.ensureDir(path.dirname(screenshotPath));
// Testcase.screenshot would resize the viewport to the element bbox.
await page.screenshot({ clip, path: screenshotPath, type: 'png' });

if (errorMessage) {
const msg = await errorMessage;
errorMessage = undefined;
console.warn(msg);
}
});
});
});
Expand Down

0 comments on commit c53e4da

Please sign in to comment.