From cf9a99b960b71a4ba5cbe7528e0c0bd35f1d9374 Mon Sep 17 00:00:00 2001 From: Vitaliy Potapov Date: Sun, 8 Dec 2024 11:47:59 +0400 Subject: [PATCH] test: html reporter more checks for beforeAll hook error --- .../specs/error-in-before-all.test.ts | 16 ++++++++++++++++ .../features/error-in-before-all/fixture.feature | 5 +++++ .../features/error-in-before-all/steps.ts | 6 +++++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/reporter-cucumber-html/features/error-in-before-all/fixture.feature diff --git a/test/reporter-cucumber-html/check-report/specs/error-in-before-all.test.ts b/test/reporter-cucumber-html/check-report/specs/error-in-before-all.test.ts index 2d8d16b2..1b5a03da 100644 --- a/test/reporter-cucumber-html/check-report/specs/error-in-before-all.test.ts +++ b/test/reporter-cucumber-html/check-report/specs/error-in-before-all.test.ts @@ -42,3 +42,19 @@ test.describe('error in named before all hook', () => { await expect(scenario.getErrors()).toContainText([`expect(true).toEqual(false)`]); }); }); + +test.describe('error in worker fixture setup', () => { + test.use({ featureUri: 'error-in-before-all/fixture.feature' }); + + test('scenario 1', async ({ scenario }) => { + await expect(scenario.getSteps()).toContainText([ + `Hook "fixture: workerFixtureWithErrorInSetup" failed: ${normalize('features/error-in-before-all/fixtures.ts')}:`, + 'GivenAction 1', + 'Givenstep that uses workerFixtureWithErrorInSetup', + 'Download trace', + ]); + await expect(scenario.getSteps('failed')).toHaveCount(1); + await expect(scenario.getSteps('skipped')).toHaveCount(2); + await expect(scenario.getErrors()).toContainText(['error in worker fixture setup']); + }); +}); diff --git a/test/reporter-cucumber-html/features/error-in-before-all/fixture.feature b/test/reporter-cucumber-html/features/error-in-before-all/fixture.feature new file mode 100644 index 00000000..b8d1291d --- /dev/null +++ b/test/reporter-cucumber-html/features/error-in-before-all/fixture.feature @@ -0,0 +1,5 @@ +Feature: error in worker fixture setup + + Scenario: scenario 1 + Given Action 1 + Given step that uses workerFixtureWithErrorInSetup diff --git a/test/reporter-cucumber-html/features/error-in-before-all/steps.ts b/test/reporter-cucumber-html/features/error-in-before-all/steps.ts index e865d2ac..cdc038f9 100644 --- a/test/reporter-cucumber-html/features/error-in-before-all/steps.ts +++ b/test/reporter-cucumber-html/features/error-in-before-all/steps.ts @@ -2,7 +2,7 @@ import { expect } from '@playwright/test'; import { createBdd } from 'playwright-bdd'; import { test } from './fixtures'; -const { BeforeAll } = createBdd(test); +const { Given, BeforeAll } = createBdd(test); BeforeAll({ tags: '@failing-anonymous-before-all-hook' }, async () => { expect(true).toEqual(false); @@ -11,3 +11,7 @@ BeforeAll({ tags: '@failing-anonymous-before-all-hook' }, async () => { BeforeAll({ name: 'my hook', tags: '@failing-named-before-all-hook' }, async () => { expect(true).toEqual(false); }); + +Given('step that uses workerFixtureWithErrorInSetup', async ({ workerFixtureWithErrorInSetup }) => { + return workerFixtureWithErrorInSetup; +});