@qavajs/playwright-runner-adapter 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +4 -3
- package/adapter/cucumber.spec.js +39 -13
- package/adapter/cucumber.spec.js.map +1 -1
- package/adapter/loader.d.ts +2 -0
- package/adapter/loader.js +1 -0
- package/adapter/loader.js.map +1 -1
- package/package.json +2 -2
- package/src/cucumber.spec.ts +46 -16
- package/src/loader.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,12 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
|
|
14
14
|
|
|
15
15
|
:microscope: - experimental
|
|
16
16
|
|
|
17
|
+
## [1.8.0]
|
|
18
|
+
- :rocket: added `gherkinDocument` to hooks parameter
|
|
19
|
+
|
|
20
|
+
## [1.7.1]
|
|
21
|
+
- :beetle: fixed `result` property in `After` and `AfterStep` hooks
|
|
22
|
+
|
|
17
23
|
## [1.7.0]
|
|
18
24
|
- :rocket: added `filter` grep utility function
|
|
19
25
|
```typescript
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ npm install @qavajs/playwright-runner-adapter
|
|
|
12
12
|
## Basic Configuration
|
|
13
13
|
|
|
14
14
|
### Create cucumber config file
|
|
15
|
-
Set
|
|
15
|
+
Set `paths` and `require` properties
|
|
16
16
|
```typescript
|
|
17
17
|
export default {
|
|
18
18
|
paths: ['test/features/*.feature'],
|
|
@@ -34,8 +34,8 @@ export default defineConfig({
|
|
|
34
34
|
|
|
35
35
|
## Advanced Configuration
|
|
36
36
|
### Customizing test instance
|
|
37
|
-
Custom test instance can be passed to world constructor as
|
|
38
|
-
And then fixtures can be connected with world instance via
|
|
37
|
+
Custom test instance can be passed to world constructor as `test` property.
|
|
38
|
+
And then fixtures can be connected with world instance via `init` function-property.
|
|
39
39
|
```typescript
|
|
40
40
|
import { test as base, expect as baseExpect } from '@playwright/test';
|
|
41
41
|
import { SettingsPage } from './settings-page';
|
|
@@ -97,5 +97,6 @@ export default defineConfig({
|
|
|
97
97
|
## Limitation
|
|
98
98
|
- ES modules are not supported (at least for node <= 22, where experimental ESM require is introduced)
|
|
99
99
|
- `setParallelCanAssign` is not supported (use playwright projects and `fullyParallel` property)
|
|
100
|
+
- `CUCUMBER_PARALLEL`, `CUCUMBER_TOTAL_WORKERS` and `CUCUMBER_WORKER_ID` env vars are not supported. Use built-in `info()` method of world property `test`
|
|
100
101
|
|
|
101
102
|
|
package/adapter/cucumber.spec.js
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const loader_1 = require("./loader");
|
|
4
4
|
const { features, supportCodeLibrary } = (0, loader_1.load)();
|
|
5
|
+
function getResult(testInfo) {
|
|
6
|
+
const message = testInfo.errors.length > 0
|
|
7
|
+
? testInfo.errors.map((err) => err.message).join('\n')
|
|
8
|
+
: undefined;
|
|
9
|
+
return {
|
|
10
|
+
duration: testInfo.duration,
|
|
11
|
+
message,
|
|
12
|
+
status: testInfo.status?.toUpperCase(),
|
|
13
|
+
exception: testInfo.error
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function getLine(step) {
|
|
17
|
+
return { location: { column: 1, file: step.uri, line: step.line } };
|
|
18
|
+
}
|
|
5
19
|
function log(data) {
|
|
6
20
|
console.log(data);
|
|
7
21
|
}
|
|
@@ -14,7 +28,7 @@ const fixture = new supportCodeLibrary.World({});
|
|
|
14
28
|
const test = fixture.test;
|
|
15
29
|
test.beforeAll(async () => {
|
|
16
30
|
for (const beforeAllHook of supportCodeLibrary.beforeTestRunHookDefinitions) {
|
|
17
|
-
const location =
|
|
31
|
+
const location = getLine(beforeAllHook);
|
|
18
32
|
await test.step('Before All', () => beforeAllHook.code.apply({}), location);
|
|
19
33
|
}
|
|
20
34
|
});
|
|
@@ -37,8 +51,9 @@ for (const feature of features) {
|
|
|
37
51
|
for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
|
|
38
52
|
if (beforeHook.appliesToTestCase(testCase)) {
|
|
39
53
|
const hookName = beforeHook.name ?? 'Before';
|
|
40
|
-
const location =
|
|
54
|
+
const location = getLine(beforeHook);
|
|
41
55
|
await test.step(hookName, () => beforeHook.code.apply(world, [{
|
|
56
|
+
gherkinDocument: feature.gherkinDocument,
|
|
42
57
|
pickle: testCase
|
|
43
58
|
}]), location);
|
|
44
59
|
}
|
|
@@ -53,10 +68,9 @@ for (const feature of features) {
|
|
|
53
68
|
{ type: 'tags', description: JSON.stringify(tag) }
|
|
54
69
|
];
|
|
55
70
|
test(testCase.name, { tag, annotation }, async () => {
|
|
56
|
-
const
|
|
57
|
-
testInfo.result = { status: 'passed' };
|
|
71
|
+
const result = { status: 'passed' };
|
|
58
72
|
for (const pickleStep of testCase.steps) {
|
|
59
|
-
if (
|
|
73
|
+
if (result.status !== 'passed') {
|
|
60
74
|
break;
|
|
61
75
|
}
|
|
62
76
|
const steps = supportCodeLibrary.stepDefinitions
|
|
@@ -66,12 +80,13 @@ for (const feature of features) {
|
|
|
66
80
|
if (steps.length > 1)
|
|
67
81
|
throw new Error(`Step '${pickleStep.text}' matches multiple step definitions`);
|
|
68
82
|
const [step] = steps;
|
|
69
|
-
const location =
|
|
83
|
+
const location = getLine(step);
|
|
70
84
|
await test.step(pickleStep.text, async () => {
|
|
71
85
|
for (const beforeStep of supportCodeLibrary.beforeTestStepHookDefinitions) {
|
|
72
86
|
if (beforeStep.appliesToTestCase(testCase)) {
|
|
73
|
-
const location =
|
|
87
|
+
const location = getLine(beforeStep);
|
|
74
88
|
await test.step('Before Step', () => beforeStep.code.apply(world, [{
|
|
89
|
+
gherkinDocument: feature.gherkinDocument,
|
|
75
90
|
pickle: testCase,
|
|
76
91
|
pickleStep
|
|
77
92
|
}]), location);
|
|
@@ -88,17 +103,26 @@ for (const feature of features) {
|
|
|
88
103
|
await step.code.apply(world, parameters);
|
|
89
104
|
}
|
|
90
105
|
catch (err) {
|
|
91
|
-
|
|
106
|
+
result.status = 'failed';
|
|
107
|
+
result.error = err;
|
|
92
108
|
throw err;
|
|
93
109
|
}
|
|
94
110
|
finally {
|
|
95
111
|
for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
|
|
96
112
|
if (afterStep.appliesToTestCase(testCase)) {
|
|
97
|
-
const location =
|
|
113
|
+
const location = getLine(afterStep);
|
|
98
114
|
await test.step('After Step', () => afterStep.code.apply(world, [{
|
|
115
|
+
gherkinDocument: feature.gherkinDocument,
|
|
116
|
+
testCaseStartedId: '0',
|
|
117
|
+
testStepId: '0',
|
|
99
118
|
pickle: testCase,
|
|
100
119
|
pickleStep,
|
|
101
|
-
result:
|
|
120
|
+
result: {
|
|
121
|
+
duration: 0,
|
|
122
|
+
message: result.error?.message,
|
|
123
|
+
status: result.status.toUpperCase(),
|
|
124
|
+
exception: result.error
|
|
125
|
+
}
|
|
102
126
|
}]), location);
|
|
103
127
|
}
|
|
104
128
|
}
|
|
@@ -117,10 +141,12 @@ for (const feature of features) {
|
|
|
117
141
|
for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
|
|
118
142
|
if (afterHook.appliesToTestCase(testCase)) {
|
|
119
143
|
const hookName = afterHook.name ?? 'After';
|
|
120
|
-
const location =
|
|
144
|
+
const location = getLine(afterHook);
|
|
121
145
|
await test.step(hookName, () => afterHook.code.apply(world, [{
|
|
146
|
+
gherkinDocument: feature.gherkinDocument,
|
|
147
|
+
testCaseStartedId: '0',
|
|
122
148
|
pickle: testCase,
|
|
123
|
-
result: testInfo
|
|
149
|
+
result: getResult(testInfo)
|
|
124
150
|
}]), location);
|
|
125
151
|
}
|
|
126
152
|
}
|
|
@@ -129,7 +155,7 @@ for (const feature of features) {
|
|
|
129
155
|
}
|
|
130
156
|
test.afterAll(async () => {
|
|
131
157
|
for (const afterAllHook of supportCodeLibrary.afterTestRunHookDefinitions) {
|
|
132
|
-
const location =
|
|
158
|
+
const location = getLine(afterAllHook);
|
|
133
159
|
await test.step('After All', () => afterAllHook.code.apply({}), location);
|
|
134
160
|
}
|
|
135
161
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cucumber.spec.js","sourceRoot":"","sources":["../src/cucumber.spec.ts"],"names":[],"mappings":";;AAAA,qCAAgC;
|
|
1
|
+
{"version":3,"file":"cucumber.spec.js","sourceRoot":"","sources":["../src/cucumber.spec.ts"],"names":[],"mappings":";;AAAA,qCAAgC;AAIhC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,IAAA,aAAI,GAAE,CAAC;AAEhD,SAAS,SAAS,CAAC,QAAkB;IACjC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;QACtC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC3D,CAAC,CAAC,SAAS,CAAC;IAChB,OAAO;QACH,QAAQ,EAAE,QAAQ,CAAC,QAAe;QAClC,OAAO;QACP,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE;QACtC,SAAS,EAAE,QAAQ,CAAC,KAAK;KAC5B,CAAC;AACN,CAAC;AAED,SAAS,OAAO,CAAC,IAAmC;IAChD,OAAO,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAC,CAAA;AACtE,CAAC;AAED,SAAS,GAAG,CAAC,IAAS;IAClB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,MAAM,CAAsB,IAAS,EAAE,OAAY;IACxD,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,YAAY,CAAC;IACnD,MAAM,W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AAE,CAAC;QACxE,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;QACvC,MAAM,IAAI,CAAC,IAAI,CACX,WAAW,EACX,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,EACjC,QAAQ,CACX,CAAA;IACL,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/adapter/loader.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export declare function loadFeatures(globPattern: string[]): {
|
|
2
2
|
feature: string | undefined;
|
|
3
|
+
gherkinDocument: import("@cucumber/messages").GherkinDocument;
|
|
3
4
|
tests: any[];
|
|
4
5
|
}[];
|
|
5
6
|
export declare function loadStepDefinitions(globPattern: string[]): import("@cucumber/cucumber/lib/support_code_library_builder/types").SupportCodeLibrary;
|
|
6
7
|
export declare function load(): {
|
|
7
8
|
features: {
|
|
8
9
|
feature: string | undefined;
|
|
10
|
+
gherkinDocument: import("@cucumber/messages").GherkinDocument;
|
|
9
11
|
tests: any[];
|
|
10
12
|
}[];
|
|
11
13
|
supportCodeLibrary: import("@cucumber/cucumber/lib/support_code_library_builder/types").SupportCodeLibrary;
|
package/adapter/loader.js
CHANGED
|
@@ -35,6 +35,7 @@ function loadFeatures(globPattern) {
|
|
|
35
35
|
const gherkinDocument = parser.parse((0, node_fs_1.readFileSync)(filePath, 'utf-8'));
|
|
36
36
|
return {
|
|
37
37
|
feature: gherkinDocument.feature?.name,
|
|
38
|
+
gherkinDocument,
|
|
38
39
|
tests: duplicates((0, gherkin_1.compile)(gherkinDocument, file, uuidFn))
|
|
39
40
|
};
|
|
40
41
|
});
|
package/adapter/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;AA4BA,
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;AA4BA,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AAI,EAAE,CAAC;QACjC,GAAG,CAAC,cAAc,CAAC,MAAM,IAAI,EAAE,CAAC;KACnC,CAAC,CAAC;IACH,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAA;AAC3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qavajs/playwright-runner-adapter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "adapter for playwright test runner",
|
|
5
5
|
"main": "adapter/index.js",
|
|
6
6
|
"types": "adapter/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"url": "https://github.com/qavajs/playwright-runner-adapter/issues"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@cucumber/gherkin": "^36.
|
|
22
|
+
"@cucumber/gherkin": "^36.1.0",
|
|
23
23
|
"@cucumber/tag-expressions": "^8.0.0",
|
|
24
24
|
"glob": "^11.0.3",
|
|
25
25
|
"@cucumber/cucumber": "^12.2.0"
|
package/src/cucumber.spec.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { load } from './loader';
|
|
2
|
+
import type { TestInfo } from '@playwright/test';
|
|
3
|
+
import type { ITestCaseHookParameter, ITestStepHookParameter } from '@cucumber/cucumber';
|
|
2
4
|
|
|
3
5
|
const { features, supportCodeLibrary } = load();
|
|
4
6
|
|
|
7
|
+
function getResult(testInfo: TestInfo) {
|
|
8
|
+
const message = testInfo.errors.length > 0
|
|
9
|
+
? testInfo.errors.map((err: any) => err.message).join('\n')
|
|
10
|
+
: undefined;
|
|
11
|
+
return {
|
|
12
|
+
duration: testInfo.duration as any,
|
|
13
|
+
message,
|
|
14
|
+
status: testInfo.status?.toUpperCase(),
|
|
15
|
+
exception: testInfo.error
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getLine(step: { uri: string, line: number }) {
|
|
20
|
+
return { location: { column: 1, file: step.uri, line: step.line }}
|
|
21
|
+
}
|
|
22
|
+
|
|
5
23
|
function log(data: any) {
|
|
6
24
|
console.log(data);
|
|
7
25
|
}
|
|
@@ -17,7 +35,7 @@ const test = fixture.test;
|
|
|
17
35
|
|
|
18
36
|
test.beforeAll(async () => {
|
|
19
37
|
for (const beforeAllHook of supportCodeLibrary.beforeTestRunHookDefinitions) {
|
|
20
|
-
const location =
|
|
38
|
+
const location = getLine(beforeAllHook);
|
|
21
39
|
await test.step(
|
|
22
40
|
'Before All',
|
|
23
41
|
() => beforeAllHook.code.apply({}),
|
|
@@ -47,12 +65,13 @@ for (const feature of features) {
|
|
|
47
65
|
for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
|
|
48
66
|
if (beforeHook.appliesToTestCase(testCase)) {
|
|
49
67
|
const hookName = beforeHook.name ?? 'Before';
|
|
50
|
-
const location =
|
|
68
|
+
const location = getLine(beforeHook);
|
|
51
69
|
await test.step(
|
|
52
70
|
hookName,
|
|
53
71
|
() => beforeHook.code.apply(world, [{
|
|
72
|
+
gherkinDocument: feature.gherkinDocument,
|
|
54
73
|
pickle: testCase
|
|
55
|
-
}]),
|
|
74
|
+
} as ITestCaseHookParameter]),
|
|
56
75
|
location
|
|
57
76
|
);
|
|
58
77
|
}
|
|
@@ -68,10 +87,9 @@ for (const feature of features) {
|
|
|
68
87
|
{ type: 'tags', description: JSON.stringify(tag) }
|
|
69
88
|
];
|
|
70
89
|
test(testCase.name, { tag, annotation }, async () => {
|
|
71
|
-
const
|
|
72
|
-
testInfo.result = { status: 'passed' };
|
|
90
|
+
const result: { status: string, error?: Error } = { status: 'passed' };
|
|
73
91
|
for (const pickleStep of testCase.steps) {
|
|
74
|
-
if (
|
|
92
|
+
if (result.status !== 'passed') {
|
|
75
93
|
break;
|
|
76
94
|
}
|
|
77
95
|
const steps = supportCodeLibrary.stepDefinitions
|
|
@@ -79,14 +97,15 @@ for (const feature of features) {
|
|
|
79
97
|
if (steps.length === 0) throw new Error(`Step '${pickleStep.text}' is not defined`);
|
|
80
98
|
if (steps.length > 1) throw new Error(`Step '${pickleStep.text}' matches multiple step definitions`);
|
|
81
99
|
const [ step ] = steps;
|
|
82
|
-
const location =
|
|
100
|
+
const location = getLine(step);
|
|
83
101
|
await test.step(pickleStep.text, async () => {
|
|
84
102
|
for (const beforeStep of supportCodeLibrary.beforeTestStepHookDefinitions) {
|
|
85
103
|
if (beforeStep.appliesToTestCase(testCase)) {
|
|
86
|
-
const location =
|
|
104
|
+
const location = getLine(beforeStep);
|
|
87
105
|
await test.step(
|
|
88
106
|
'Before Step',
|
|
89
107
|
() => beforeStep.code.apply(world, [{
|
|
108
|
+
gherkinDocument: feature.gherkinDocument,
|
|
90
109
|
pickle: testCase,
|
|
91
110
|
pickleStep
|
|
92
111
|
}]),
|
|
@@ -104,19 +123,28 @@ for (const feature of features) {
|
|
|
104
123
|
try {
|
|
105
124
|
await step.code.apply(world, parameters);
|
|
106
125
|
} catch (err: any) {
|
|
107
|
-
|
|
126
|
+
result.status = 'failed';
|
|
127
|
+
result.error = err;
|
|
108
128
|
throw err;
|
|
109
129
|
} finally {
|
|
110
130
|
for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
|
|
111
131
|
if (afterStep.appliesToTestCase(testCase)) {
|
|
112
|
-
const location =
|
|
132
|
+
const location = getLine(afterStep);
|
|
113
133
|
await test.step(
|
|
114
134
|
'After Step',
|
|
115
135
|
() => afterStep.code.apply(world, [{
|
|
136
|
+
gherkinDocument: feature.gherkinDocument,
|
|
137
|
+
testCaseStartedId: '0',
|
|
138
|
+
testStepId: '0',
|
|
116
139
|
pickle: testCase,
|
|
117
140
|
pickleStep,
|
|
118
|
-
result:
|
|
119
|
-
|
|
141
|
+
result: {
|
|
142
|
+
duration: 0 as any,
|
|
143
|
+
message: result.error?.message,
|
|
144
|
+
status: result.status.toUpperCase(),
|
|
145
|
+
exception: result.error
|
|
146
|
+
}
|
|
147
|
+
} as ITestStepHookParameter]),
|
|
120
148
|
location
|
|
121
149
|
);
|
|
122
150
|
}
|
|
@@ -137,13 +165,15 @@ for (const feature of features) {
|
|
|
137
165
|
for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
|
|
138
166
|
if (afterHook.appliesToTestCase(testCase)) {
|
|
139
167
|
const hookName = afterHook.name ?? 'After';
|
|
140
|
-
const location =
|
|
168
|
+
const location = getLine(afterHook);
|
|
141
169
|
await test.step(
|
|
142
170
|
hookName,
|
|
143
171
|
() => afterHook.code.apply(world, [{
|
|
172
|
+
gherkinDocument: feature.gherkinDocument,
|
|
173
|
+
testCaseStartedId: '0',
|
|
144
174
|
pickle: testCase,
|
|
145
|
-
result: testInfo
|
|
146
|
-
}]),
|
|
175
|
+
result: getResult(testInfo)
|
|
176
|
+
} as ITestCaseHookParameter]),
|
|
147
177
|
location
|
|
148
178
|
);
|
|
149
179
|
}
|
|
@@ -155,7 +185,7 @@ for (const feature of features) {
|
|
|
155
185
|
|
|
156
186
|
test.afterAll(async () => {
|
|
157
187
|
for (const afterAllHook of supportCodeLibrary.afterTestRunHookDefinitions) {
|
|
158
|
-
const location =
|
|
188
|
+
const location = getLine(afterAllHook);
|
|
159
189
|
await test.step(
|
|
160
190
|
'After All',
|
|
161
191
|
() => afterAllHook.code.apply({}),
|
package/src/loader.ts
CHANGED
|
@@ -33,6 +33,7 @@ export function loadFeatures(globPattern: string[]) {
|
|
|
33
33
|
const gherkinDocument = parser.parse(readFileSync(filePath, 'utf-8'));
|
|
34
34
|
return {
|
|
35
35
|
feature: gherkinDocument.feature?.name,
|
|
36
|
+
gherkinDocument,
|
|
36
37
|
tests: duplicates(compile(gherkinDocument, file, uuidFn) as any)
|
|
37
38
|
}
|
|
38
39
|
});
|