How can I bubble up more information about a failed test? Ideally I want a second parameter on the except function where I can pass a string that would show up on the console. Something like:
var i = 0;
var j = 0;
expect( i / j, `failed when dividing ${i} ${j}` )
I also tried this:
test.describe("Test description", () => {
test("Test name", async ({ page }) => {
...snip...
await test.step("Testing DIV0 is fail", async () => {
await expect(4/0).toBe(5);
});
...snip...
});
});
The command line might quickly flash the text Testing DIV0 is fail
for a 1/1000th of a second. This is not helpful. Basically Playwright is unusable if I can't find the problem I'm trying to discover.
What I see:
1) myTests.spec.ts:40:2 › Test description
Error: expect(received).toBe(expected) // Object.is equality
Expected: 5
Received: Infinity
44 | await test.step("Testing DIV0 is fail", async () => {
> 45 | await expect(4/0).toBe(5);
| ^
46 | });
at myTests.spec.ts:45:22
at TestTypeImpl._step (...\node_modules\@playwright\test\lib\test\testType.js:213:13)
at Function.step (...\node_modules\@playwright\test\lib\test\transform.js:133:12)
at ...\tests\myTests.spec.ts:44:14
at WorkerRunner._runTestWithBeforeHooks (...\node_modules\@playwright\test\lib\test\workerRunner.js:450:7)
Slow test: basicPageChecks.spec.ts (24s)
1 failed
myTests.spec.ts:40:2 › Test description
12 skipped
I could just as easily add a comment in the code. Or add logging.
Perhaps this additional data is available in a report?? Am I missing something??