-
-
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: prepare for after-all html report
- Loading branch information
Showing
7 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
test/reporter-cucumber-html/check-report/specs/error-in-after-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,28 @@ | ||
import { test } from '../fixtures'; | ||
|
||
// All these tests are skipped because they are marked as passed in Cucumber html report. | ||
// It's because afterAll hooks run in worker fixture teardown phase that is not related to any test. | ||
// In case of error, this error is reported via reporter.onError, not in test results. | ||
// | ||
// It would be better to run afterAll hooks inside test.afterAll(), | ||
// but it's will work incorrectly if single afterAll hook is tagged to several features, | ||
// because it will be run several times. | ||
|
||
test.describe.skip('error in anonymous after all hook', () => { | ||
test.use({ featureUri: 'error-in-after-all/anonymous.feature' }); | ||
|
||
test('scenario 1', async () => {}); | ||
test('scenario 2', async () => {}); | ||
}); | ||
|
||
test.describe.skip('error in named after all hook', () => { | ||
test.use({ featureUri: 'error-in-after-all/named.feature' }); | ||
|
||
test('scenario 1', async () => {}); | ||
}); | ||
|
||
test.describe.skip('error in worker fixture teardown', () => { | ||
test.use({ featureUri: 'error-in-after-all/fixture.feature' }); | ||
|
||
test('scenario 1', async () => {}); | ||
}); |
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
8 changes: 8 additions & 0 deletions
8
test/reporter-cucumber-html/features/error-in-after-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-after-all-hook | ||
Feature: error in anonymous after-all hook | ||
|
||
Scenario: scenario 1 | ||
Given Action 1 | ||
|
||
Scenario: scenario 2 | ||
Given Action 2 |
5 changes: 5 additions & 0 deletions
5
test/reporter-cucumber-html/features/error-in-after-all/fixture.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 @@ | ||
Feature: error in worker fixture teardown (after-all) | ||
|
||
Scenario: scenario 1 | ||
Given Action 1 | ||
Given step that uses workerFixtureWithErrorInTeardown |
24 changes: 24 additions & 0 deletions
24
test/reporter-cucumber-html/features/error-in-after-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, | ||
{ | ||
workerFixtureWithErrorInTeardown: void; | ||
workerFixtureWithTimeoutInTeardown: void; | ||
} | ||
>({ | ||
workerFixtureWithErrorInTeardown: [ | ||
async ({}, use) => { | ||
await use(); | ||
throw new Error('error in worker fixture setup'); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
workerFixtureWithTimeoutInTeardown: [ | ||
async ({}, use, workerInfo) => { | ||
await use(); | ||
await new Promise((r) => setTimeout(r, workerInfo.project.timeout + 100)); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
}); |
5 changes: 5 additions & 0 deletions
5
test/reporter-cucumber-html/features/error-in-after-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-after-all-hook | ||
Feature: error in named after-all hook | ||
|
||
Scenario: scenario 1 | ||
Given Action 1 |
20 changes: 20 additions & 0 deletions
20
test/reporter-cucumber-html/features/error-in-after-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,20 @@ | ||
import { expect } from '@playwright/test'; | ||
import { createBdd } from 'playwright-bdd'; | ||
import { test } from './fixtures'; | ||
|
||
const { Given, AfterAll } = createBdd(test); | ||
|
||
AfterAll({ tags: '@failing-anonymous-after-all-hook' }, async () => { | ||
expect(true).toEqual(false); | ||
}); | ||
|
||
AfterAll({ name: 'my hook', tags: '@failing-named-after-all-hook' }, async () => { | ||
expect(true).toEqual(false); | ||
}); | ||
|
||
Given( | ||
'step that uses workerFixtureWithErrorInTeardown', | ||
async ({ workerFixtureWithErrorInTeardown }) => { | ||
return workerFixtureWithErrorInTeardown; | ||
}, | ||
); |