-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add reporter test for error in before all
- Loading branch information
Showing
6 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
test/reporter-cucumber-html/check-report/specs/error-in-before-all.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { normalize } from 'node:path'; | ||
import { expect } from '@playwright/test'; | ||
import { test } from '../fixtures'; | ||
|
||
test.describe('error in anonymous before all hook', () => { | ||
test.use({ featureUri: 'error-in-before-all/anonymous.feature' }); | ||
|
||
test('scenario 1', async ({ scenario }) => { | ||
await expect(scenario.getSteps()).toContainText([ | ||
`Hook "BeforeAll hook" failed: ${normalize('features/error-in-before-all/steps.ts')}:`, // prettier-ignore | ||
'GivenAction 1', | ||
'Download trace', | ||
]); | ||
await expect(scenario.getSteps('failed')).toHaveCount(1); | ||
await expect(scenario.getSteps('skipped')).toHaveCount(1); | ||
await expect(scenario.getErrors()).toContainText([`expect(true).toEqual(false)`]); | ||
}); | ||
|
||
test('scenario 2', async ({ scenario }) => { | ||
await expect(scenario.getSteps()).toContainText([ | ||
`Hook "BeforeAll hook" failed: ${normalize('features/error-in-before-all/steps.ts')}:`, // prettier-ignore | ||
'GivenAction 2', | ||
'Download trace', | ||
]); | ||
await expect(scenario.getSteps('failed')).toHaveCount(1); | ||
await expect(scenario.getSteps('skipped')).toHaveCount(1); | ||
await expect(scenario.getErrors()).toContainText([`expect(true).toEqual(false)`]); | ||
}); | ||
}); | ||
|
||
test.describe('error in named before all hook', () => { | ||
test.use({ featureUri: 'error-in-before-all/named.feature' }); | ||
|
||
test('scenario 1', async ({ scenario }) => { | ||
await expect(scenario.getSteps()).toContainText([ | ||
`Hook "my hook" failed: ${normalize('features/error-in-before-all/steps.ts')}:`, // prettier-ignore | ||
'GivenAction 1', | ||
'Download trace', | ||
]); | ||
await expect(scenario.getSteps('failed')).toHaveCount(1); | ||
await expect(scenario.getSteps('skipped')).toHaveCount(1); | ||
await expect(scenario.getErrors()).toContainText([`expect(true).toEqual(false)`]); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
test/reporter-cucumber-html/features/error-in-before-all/anonymous.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@failing-anonymous-before-all-hook | ||
Feature: anonymous before-all hook | ||
|
||
Scenario: scenario 1 | ||
Given Action 1 | ||
|
||
Scenario: scenario 2 | ||
Given Action 2 |
24 changes: 24 additions & 0 deletions
24
test/reporter-cucumber-html/features/error-in-before-all/fixtures.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { test as base } from 'playwright-bdd'; | ||
|
||
export const test = base.extend< | ||
object, | ||
{ | ||
workerFixtureWithErrorInSetup: void; | ||
workerFixtureWithTimeoutInSetup: void; | ||
} | ||
>({ | ||
workerFixtureWithErrorInSetup: [ | ||
async ({}, use) => { | ||
throw new Error('error in worker fixture setup'); | ||
await use(); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
workerFixtureWithTimeoutInSetup: [ | ||
async ({}, use, workerInfo) => { | ||
await new Promise((r) => setTimeout(r, workerInfo.project.timeout + 100)); | ||
await use(); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
}); |
5 changes: 5 additions & 0 deletions
5
test/reporter-cucumber-html/features/error-in-before-all/named.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@failing-named-before-all-hook | ||
Feature: named before-all hook | ||
|
||
Scenario: scenario 1 | ||
Given Action 1 |
3 changes: 0 additions & 3 deletions
3
test/reporter-cucumber-html/features/error-in-before-all/sample.feature
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
test/reporter-cucumber-html/features/error-in-before-all/steps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { expect } from '@playwright/test'; | ||
import { createBdd } from 'playwright-bdd'; | ||
import { test } from './fixtures'; | ||
|
||
const { BeforeAll } = createBdd(test); | ||
|
||
BeforeAll({ tags: '@failing-anonymous-before-all-hook' }, async () => { | ||
expect(true).toEqual(false); | ||
}); | ||
|
||
BeforeAll({ name: 'my hook', tags: '@failing-named-before-all-hook' }, async () => { | ||
expect(true).toEqual(false); | ||
}); |