From bc2d4302f5bd2f0628a717920881a2607e1c31b2 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 15 Feb 2024 09:45:48 -0800 Subject: [PATCH] test: fix a broken reporter test (#29514) It failed to print an error with missing stack, e.g. a timeout error. --- tests/playwright-test/test-step.spec.ts | 26 +++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.ts index 6799ee5b55..5f1b386ce3 100644 --- a/tests/playwright-test/test-step.spec.ts +++ b/tests/playwright-test/test-step.spec.ts @@ -47,8 +47,8 @@ class Reporter { distillError(error) { return { error: { - message: stripAnsi(error.message), - stack: stripAnsi(error.stack), + message: stripAnsi(error.message || ''), + stack: stripAnsi(error.stack || ''), } }; } @@ -351,6 +351,12 @@ test('should not report nested after hooks', async ({ runInlineTest }) => { }, ], }, + { + error: { + message: 'Test timeout of 2000ms exceeded.', + stack: '' + }, + }, ]); }); @@ -972,6 +978,18 @@ test('should not mark page.close as failed when page.click fails', async ({ runI }, ], }, + { + error: { + message: 'Test timeout of 2000ms exceeded.', + stack: '', + }, + }, + { + error: { + message: expect.stringContaining('Error: page.click'), + stack: expect.stringContaining('Error: page.click'), + }, + }, ]); }); @@ -1172,7 +1190,7 @@ test('should propagate nested soft errors', async ({ runInlineTest }) => { expect.soft(1).toBe(2); }); }); - + await test.step('second outer', async () => { await test.step('second inner', async () => { expect(1).toBe(2); @@ -1267,7 +1285,7 @@ test('should not propagate nested hard errors', async ({ runInlineTest }) => { } }); }); - + await test.step('second outer', async () => { await test.step('second inner', async () => { expect(1).toBe(2);