[TS] Log console messages in browser tests via playwright
authorMatt Corallo <git@bluematt.me>
Mon, 17 Jan 2022 13:04:40 +0000 (13:04 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 17 Jan 2022 14:02:33 +0000 (14:02 +0000)
ts/test/browser.mjs

index 03b5141415f860e53d4cdc9b31c1bfbdf0e1e086..0d9e9dd9ec414854fe42a7189046190c0f830914 100644 (file)
@@ -5,6 +5,12 @@ for (const browserType of [chromium, firefox]) { // We'd like to test webkit, bu
        const browser = await browserType.launch();
        const context = await browser.newContext();
        const page = await context.newPage();
+       page.on('console', async msg => {
+               const values = [];
+               for (const arg of msg.args())
+                       values.push(await arg.jsonValue());
+               console.log(...values);
+       });
        await page.goto('http://localhost:8000/test/index.html');
        const ret = await page.evaluate(() => {
                return test_runner('../liblightningjs.wasm');