Skip to content

Commit

Permalink
test: html reporter before hook error
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Dec 8, 2024
1 parent 0256a71 commit 6312d6a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ test('error in anonymous before hook', async ({ scenario }) => {
]);
await expect(scenario.getSteps('failed')).toHaveCount(1);
await expect(scenario.getSteps('skipped')).toHaveCount(1);
await expect(scenario.getTags()).toContainText(['@failing-anonymous-hook']);
await expect(scenario.getErrors()).toContainText(['Timed out']);
await expect(scenario.getErrors()).toContainText([`Before({ tags: '@failing-anonymous-hook' }`]);
await expect(scenario.getTags()).toContainText(['@failing-anonymous-before-hook']);
await expect(scenario.getErrors()).toContainText([`expect(page).toHaveTitle`]);
});

test('error in named before hook', async ({ scenario }) => {
Expand All @@ -25,9 +24,8 @@ test('error in named before hook', async ({ scenario }) => {
]);
await expect(scenario.getSteps('failed')).toHaveCount(1);
await expect(scenario.getSteps('skipped')).toHaveCount(1);
await expect(scenario.getTags()).toContainText(['@failing-named-hook']);
await expect(scenario.getErrors()).toContainText(['Timed out']);
await expect(scenario.getErrors()).toContainText([`Before({ name: 'failing named before hook'`]);
await expect(scenario.getTags()).toContainText(['@failing-named-before-hook']);
await expect(scenario.getErrors()).toContainText([`expect(page).toHaveTitle`]);
});

test('error in fixture setup (no step)', async ({ scenario }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Feature: error-in-before

@failing-anonymous-hook
@failing-anonymous-before-hook
Scenario: error in anonymous before hook
Given Action 1

@failing-named-hook
@failing-named-before-hook
Scenario: error in named before hook
Given Action 1

Expand Down
14 changes: 9 additions & 5 deletions test/reporter-cucumber-html/features/error-in-before/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import { test } from './fixtures';

const { Given, Before } = createBdd(test);

Before({ name: 'failing named before hook', tags: '@failing-named-hook' }, async ({ page }) => {
await expect(page).toHaveTitle('Some title1');
// 'page' arg is important to have a screenshot in the report
Before({ tags: '@failing-anonymous-before-hook' }, async ({ page }) => {
await expect(page).toHaveTitle('foo');
});

Before({ tags: '@failing-anonymous-hook' }, async ({ page }) => {
await expect(page).toHaveTitle('Some title2');
});
Before(
{ name: 'failing named before hook', tags: '@failing-named-before-hook' },
async ({ page }) => {
await expect(page).toHaveTitle('foo');
},
);

Given('step that uses fixtureWithErrorInSetup', async ({ fixtureWithErrorInSetup }) => {
return fixtureWithErrorInSetup;
Expand Down

0 comments on commit 6312d6a

Please sign in to comment.