From 8eb346de25103c01802abfc0b17839d6d09e89a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 24 Nov 2021 10:58:26 +0100 Subject: [PATCH] Displaying logs in case of error --- tests/.testcaferc.js | 2 +- tests/tests/test.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/.testcaferc.js b/tests/.testcaferc.js index 20529860..8d2ce364 100644 --- a/tests/.testcaferc.js +++ b/tests/.testcaferc.js @@ -1,4 +1,4 @@ -const BROWSER = process.env.BROWSER || "chrome --use-fake-device-for-media-stream"; +const BROWSER = process.env.BROWSER || "chrome --use-fake-ui-for-media-stream --use-fake-device-for-media-stream"; module.exports = { "browsers": BROWSER, diff --git a/tests/tests/test.ts b/tests/tests/test.ts index e7f3bdba..a88813c1 100644 --- a/tests/tests/test.ts +++ b/tests/tests/test.ts @@ -29,15 +29,21 @@ test("Test that variables cache in the back don't prevent setting a variable in .click('button.selectCharacterButtonRight') .click('button.selectCharacterButtonRight') .click('button.selectCharacterSceneFormSubmit') - .click('button.letsgo'); + .click('button.letsgo') + .wait(1000); //.takeScreenshot('after_switch.png'); const messages = await t.getBrowserConsoleMessages(); const logs = messages['log']; - console.log(logs); - const lastMessage = logs.pop(); // Let's check we successfully manage to save the variable value. - await t.expect(lastMessage).eql('SUCCESS!'); + await t.expect(logs).contains('SUCCESS!'); + + t.ctx.passed = true; +}).after(async t => { + if (!t.ctx.passed) { + console.log("Test failed. Browser logs:") + console.log(await t.getBrowserConsoleMessages()); + } });