Skip to content

Commit

Permalink
test: html reporter more checks for beforeAll hook error
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Dec 8, 2024
1 parent 13a9528 commit cf9a99b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: error in worker fixture setup

Scenario: scenario 1
Given Action 1
Given step that uses workerFixtureWithErrorInSetup
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
});

0 comments on commit cf9a99b

Please sign in to comment.