Skip to content

Commit 3efca50

Browse files
added support of named hooks (#17)
1 parent 3d1ef2f commit 3efca50

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1010
:pencil: - chore
1111
:microscope: - experimental
1212

13+
## [0.7.0]
14+
- :rocket: added support of named hooks
15+
1316
## [0.6.1]
1417
- :beetle: make params in hooks closer to cucumber types
1518

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@qavajs/playwright-runner-adapter",
3-
"version": "0.6.1",
3+
"version": "0.7.0",
44
"description": "adapter for playwright test runner",
55
"scripts": {
66
"build": "tsc",

src/adapter.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ for (const feature of features) {
3737
const result: { status: string, error?: any } = { status: 'passed' };
3838
for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
3939
if (beforeHook.appliesToTestCase(testCase)) {
40-
await test.step('Before', async () => {
40+
const hookName = beforeHook.name ?? 'Before';
41+
await test.step(hookName, async () => {
4142
await beforeHook.code.apply(world, [{
4243
pickle: testCase
4344
}]);
@@ -86,7 +87,8 @@ for (const feature of features) {
8687
}
8788
for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
8889
if (afterHook.appliesToTestCase(testCase)) {
89-
await test.step('After', async () => {
90+
const hookName = afterHook.name ?? 'After';
91+
await test.step(hookName, async () => {
9092
await afterHook.code.apply(world, [{
9193
pickle: testCase, result
9294
}]);

test/step_definitions/steps.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,12 @@ AfterStep(async function (this: ExtendedPlaywrightWorld, testCase: ITestStepHook
9898
this.expect(testCase.pickleStep).toBeTruthy();
9999
this.expect(testCase.result).toBeTruthy();
100100
});
101+
102+
Before({name: 'Named Before'}, async function (this: ExtendedPlaywrightWorld, testCase: ITestCaseHookParameter) {
103+
this.expect(testCase.pickle).toBeTruthy();
104+
});
105+
106+
After({name: 'Named After'}, async function (this: ExtendedPlaywrightWorld, testCase: ITestCaseHookParameter) {
107+
this.expect(testCase.pickle).toBeTruthy();
108+
this.expect(testCase.result).toBeTruthy();
109+
});

0 commit comments

Comments
 (0)