Skip to content

Commit

Permalink
test: fix html reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Dec 7, 2024
1 parent 51ec821 commit 7dd2c43
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ test.use({ featureUri: 'error-in-after/sample.feature' });
test('error in fixture teardown (no step)', async ({ scenario }) => {
await expect(scenario.getSteps()).toContainText([
'my attachment|before use',
'Givenstep with page',
'Givenstep that uses fixtureWithErrorInTeardown',
'WhenAction 1',
`Hook "fixture: fixtureWithErrorInTeardown" failed: ${normalize('features/error-in-after/fixtures.ts')}:`,
Expand All @@ -24,7 +25,7 @@ test('error in fixture teardown (no step)', async ({ scenario }) => {
'my attachment|before use', // prettier-ignore
'my attachment|after use',
]);
await expect(scenario.getSteps('passed')).toHaveCount(2);
await expect(scenario.getSteps('passed')).toHaveCount(3);
await expect(scenario.getSteps('failed')).toHaveCount(1);
await expect(scenario.getSteps('skipped')).toHaveCount(0);
await expect(scenario.getErrors()).toContainText(['error in fixture teardown']);
Expand All @@ -33,6 +34,7 @@ test('error in fixture teardown (no step)', async ({ scenario }) => {
test('error in fixture teardown (with step)', async ({ scenario }) => {
await expect(scenario.getSteps()).toContainText([
'my attachment|outside step (before use)',
'Givenstep with page',
'Givenstep that uses fixtureWithErrorInTeardownStep',
'WhenAction 1',
`Hook "step inside fixture" failed: ${normalize('features/error-in-after/fixtures.ts')}:`,
Expand All @@ -46,7 +48,7 @@ test('error in fixture teardown (with step)', async ({ scenario }) => {
'my attachment|in step',
'my attachment|outside step (after use)',
]);
await expect(scenario.getSteps('passed')).toHaveCount(2);
await expect(scenario.getSteps('passed')).toHaveCount(3);
await expect(scenario.getSteps('failed')).toHaveCount(1);
await expect(scenario.getSteps('skipped')).toHaveCount(0);
await expect(scenario.getErrors()).toContainText(['error in fixture teardown']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { test } from '../fixtures';

test.use({ featureUri: 'error-in-step/sample.feature' });

test('failing by step assertion', async ({ scenario }) => {
test('error in step', async ({ scenario }) => {
await expect(scenario.getSteps()).toContainText([
'Givenfailing step', // prettier-ignore
'screenshotDownload trace',
Expand All @@ -13,22 +13,23 @@ test('failing by step assertion', async ({ scenario }) => {
]);
});

test('failing by step timeout', async ({ scenario }) => {
test('timeout in step', async ({ scenario }) => {
await expect(scenario.getSteps()).toContainText([
'GivenAction 0',
'Giventimeouted step',
'WhenAction 1',
// not 'screenshot', b/c no page
// 'screenshot',
'Download trace',
// 'Download trace' can be attached to 'timeouted step' (pw 1.43) - is it a bug?
// 'Download trace',
]);
// don't check passed/skipped steps counts b/c in different PW versions it's different
await expect(scenario.getErrors()).toContainText([/Test timeout of \d+ms exceeded/]);
});

test('failing match snapshot', async ({ scenario }) => {
await expect(scenario.getSteps()).toContainText([
'Whenopen page "https://example.com"',
'Whenopen example.com',
'Thenpage title snapshot matches the golden one',
]);
await expect(scenario.getAttachments()).toHaveText([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Feature: error-in-after

Scenario: error in fixture teardown (no step)
Given step with page
Given step that uses fixtureWithErrorInTeardown
When Action 1

Scenario: error in fixture teardown (with step)
Given step with page
Given step that uses fixtureWithErrorInTeardownStep
When Action 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ Feature: error-in-step

# - Increased timeout b/c this test opens page
@timeout:10_000
Scenario: failing by step assertion
Scenario: error in step
Given failing step

Scenario: failing by step timeout
Scenario: timeout in step
Given Action 0
Given timeouted step
When Action 1
Expand All @@ -14,7 +14,7 @@ Feature: error-in-step
# - Increased timeout b/c this test opens page
@timeout:10_000
Scenario: failing match snapshot
When open page "https://example.com"
When open example.com
Then page title snapshot matches the golden one

Scenario: soft assertions
Expand Down
9 changes: 7 additions & 2 deletions test/reporter-cucumber-html/features/shared.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Given('failing step', async ({ page }) => {
await expect(page.getByText('missing string')).toBeVisible();
});

When('open page {string}', async ({ page }, url: string) => {
await page.goto(url);
// using 'page' here to have a screenshot in report
When('step with page', async ({ page }) => {
return page;
});

When('open example.com', async ({ page }) => {
await page.goto('https://example.com');
});

0 comments on commit 7dd2c43

Please sign in to comment.