@qavajs/playwright-runner-adapter 1.8.1 → 1.9.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 +3 -0
- package/adapter/cucumber.spec.js +27 -15
- package/adapter/cucumber.spec.js.map +1 -1
- package/adapter/loader.d.ts +9 -10
- package/adapter/loader.js.map +1 -1
- package/package.json +4 -4
- package/src/cucumber.spec.ts +35 -19
- package/src/loader.ts +10 -3
package/CHANGELOG.md
CHANGED
package/adapter/cucumber.spec.js
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
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 getTestId(testInfo) {
|
|
6
|
+
return testInfo
|
|
7
|
+
.annotations
|
|
8
|
+
.find((annotation) => annotation.type === 'testId')
|
|
9
|
+
.description;
|
|
10
|
+
}
|
|
5
11
|
function getResult(testInfo) {
|
|
6
12
|
const message = testInfo.errors.length > 0
|
|
7
13
|
? testInfo.errors.map((err) => err.message).join('\n')
|
|
@@ -32,21 +38,24 @@ test.beforeAll(async () => {
|
|
|
32
38
|
await test.step('Before All', () => beforeAllHook.code.apply({}), location);
|
|
33
39
|
}
|
|
34
40
|
});
|
|
41
|
+
const worlds = new Map();
|
|
35
42
|
for (const feature of features) {
|
|
36
43
|
const tests = feature.tests;
|
|
37
44
|
test.describe(feature.feature, async () => {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
const worldFactory = (fixtures) => {
|
|
46
|
+
const world = new supportCodeLibrary.World({
|
|
47
|
+
log,
|
|
48
|
+
attach,
|
|
49
|
+
supportCodeLibrary
|
|
50
|
+
});
|
|
51
|
+
Object.assign(world, fixtures);
|
|
52
|
+
worlds.set(getTestId(test.info()), world);
|
|
53
|
+
};
|
|
54
|
+
worldFactory.toString = () => { return fixture.init.toString(); };
|
|
55
|
+
test.beforeEach('World', worldFactory);
|
|
44
56
|
test.beforeEach('Before Hooks', async () => {
|
|
45
|
-
const testId = test
|
|
46
|
-
|
|
47
|
-
.annotations
|
|
48
|
-
.find((annotation) => annotation.type === 'testId')
|
|
49
|
-
.description;
|
|
57
|
+
const testId = getTestId(test.info());
|
|
58
|
+
const world = worlds.get(testId);
|
|
50
59
|
const testCase = tests.find(test => test.id === testId);
|
|
51
60
|
for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
|
|
52
61
|
if (beforeHook.appliesToTestCase(testCase)) {
|
|
@@ -68,6 +77,7 @@ for (const feature of features) {
|
|
|
68
77
|
{ type: 'tags', description: JSON.stringify(tag) }
|
|
69
78
|
];
|
|
70
79
|
test(testCase.name, { tag, annotation }, async () => {
|
|
80
|
+
const world = worlds.get(testCase.id);
|
|
71
81
|
const result = { status: 'passed' };
|
|
72
82
|
for (const pickleStep of testCase.steps) {
|
|
73
83
|
if (result.status !== 'passed') {
|
|
@@ -133,10 +143,8 @@ for (const feature of features) {
|
|
|
133
143
|
}
|
|
134
144
|
test.afterEach('After Hooks', async () => {
|
|
135
145
|
const testInfo = test.info();
|
|
136
|
-
const testId = testInfo
|
|
137
|
-
|
|
138
|
-
.find((annotation) => annotation.type === 'testId')
|
|
139
|
-
.description;
|
|
146
|
+
const testId = getTestId(testInfo);
|
|
147
|
+
const world = worlds.get(testId);
|
|
140
148
|
const testCase = tests.find(test => test.id === testId);
|
|
141
149
|
for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
|
|
142
150
|
if (afterHook.appliesToTestCase(testCase)) {
|
|
@@ -151,6 +159,10 @@ for (const feature of features) {
|
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
});
|
|
162
|
+
test.afterEach('World', async () => {
|
|
163
|
+
const testId = getTestId(test.info());
|
|
164
|
+
worlds.delete(testId);
|
|
165
|
+
});
|
|
154
166
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AAC,CAAC;oBACpC,MAAM,IAAI,CAAC,IAAI,CACX,QAAQ,EACR,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;4BAC/B,eAAe,EAAE,OAAO,CAAC,eAAe;4BACxC,iBAAiB,EAAE,GAAG;4BACtB,MAAM,EAAE,QAAQ;4BAChB,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC;yBACJ,CAAC,CAAC,EAC7B,QAAQ,CACX,CAAC;gBACN,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;YAC/B,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACtC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IAEP,CAAC,CAAC,CAAC;AACP,CAAC;AAED,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE;IACrB,KAAK,MAAM,YAAY,IAAI,kBAAkB,CAAC,2BAA2B,EAAE,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,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { Pickle, GherkinDocument } from '@cucumber/messages';
|
|
2
|
+
type Feature = {
|
|
3
|
+
feature?: string;
|
|
4
|
+
gherkinDocument: GherkinDocument;
|
|
5
|
+
tests: readonly Pickle[];
|
|
6
|
+
};
|
|
7
|
+
export declare function loadFeatures(globPattern: string[]): Feature[];
|
|
6
8
|
export declare function loadStepDefinitions(globPattern: string[]): import("@cucumber/cucumber/lib/support_code_library_builder/types").SupportCodeLibrary;
|
|
7
9
|
export declare function load(): {
|
|
8
|
-
features:
|
|
9
|
-
feature: string | undefined;
|
|
10
|
-
gherkinDocument: import("@cucumber/messages").GherkinDocument;
|
|
11
|
-
tests: any[];
|
|
12
|
-
}[];
|
|
10
|
+
features: Feature[];
|
|
13
11
|
supportCodeLibrary: import("@cucumber/cucumber/lib/support_code_library_builder/types").SupportCodeLibrary;
|
|
14
12
|
};
|
|
13
|
+
export {};
|
package/adapter/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;AAmCA,oCAWC;AAED,kDASC;AAED,oBAYC;AAvED,qCAAuC;AACvC,yCAA0C;AAC1C,6CAAyC;AACzC,+CAA4F;AAC5F,iDAA+D;AAE/D,+BAAgC;AAChC,uDAAoD;AAEpD,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAA,wBAAU,GAAE,CAAC;AAClC,MAAM,OAAO,GAAG,IAAI,oBAAU,CAAC,MAAM,CAAC,CAAC;AACvC,MAAM,OAAO,GAAG,IAAI,oCAA0B,EAAE,CAAC;AACjD,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAE3C,SAAS,UAAU,CAAC,KAAwB;IACxC,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACpB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,GA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AQ,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,oCAAyB,CAAC,QAAQ,EAAE,CAAC;AAChD,CAAC;AAED,SAAgB,IAAI;IAChB,MAAM,MAAM,GAAG,OAAO,CAAC,IAAA,gBAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;IAC/E,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,SAAS,CAAC;IAEjD,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,YAAY,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;QAC3C,GAAG,CAAC,cAAc,CAAC,cAAc,IAAI,EAAE,CAAC;QACxC,GAAG,CAAC,cAAc,CAAC,OAAO,IAAI,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.9.0",
|
|
4
4
|
"description": "adapter for playwright test runner",
|
|
5
5
|
"main": "adapter/index.js",
|
|
6
6
|
"types": "adapter/index.d.ts",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"url": "https://github.com/qavajs/playwright-runner-adapter/issues"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@cucumber/gherkin": "^
|
|
22
|
+
"@cucumber/gherkin": "^37.0.0",
|
|
23
23
|
"@cucumber/tag-expressions": "^8.0.0",
|
|
24
|
-
"glob": "^
|
|
24
|
+
"glob": "^13.0.0",
|
|
25
25
|
"@cucumber/cucumber": "^12.2.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@playwright/test": "^1.
|
|
28
|
+
"@playwright/test": "^1.57.0",
|
|
29
29
|
"@types/node": "^24.10.1",
|
|
30
30
|
"typescript": "^5.9.3"
|
|
31
31
|
},
|
package/src/cucumber.spec.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { load } from './loader';
|
|
2
|
-
import type { TestInfo } from '@playwright/test';
|
|
2
|
+
import type { TestInfo, TestType } from '@playwright/test';
|
|
3
3
|
import type { ITestCaseHookParameter, ITestStepHookParameter } from '@cucumber/cucumber';
|
|
4
4
|
|
|
5
5
|
const { features, supportCodeLibrary } = load();
|
|
6
6
|
|
|
7
|
+
function getTestId(testInfo: TestInfo) {
|
|
8
|
+
return testInfo
|
|
9
|
+
.annotations
|
|
10
|
+
.find((annotation: { type: string }) => annotation.type === 'testId')!
|
|
11
|
+
.description;
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
function getResult(testInfo: TestInfo) {
|
|
8
15
|
const message = testInfo.errors.length > 0
|
|
9
16
|
? testInfo.errors.map((err: any) => err.message).join('\n')
|
|
@@ -31,7 +38,7 @@ function attach(this: { test: any }, body: any, details: any) {
|
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
const fixture = new supportCodeLibrary.World({});
|
|
34
|
-
const test = fixture.test;
|
|
41
|
+
const test: TestType<any, any> = fixture.test;
|
|
35
42
|
|
|
36
43
|
test.beforeAll(async () => {
|
|
37
44
|
for (const beforeAllHook of supportCodeLibrary.beforeTestRunHookDefinitions) {
|
|
@@ -44,24 +51,29 @@ test.beforeAll(async () => {
|
|
|
44
51
|
}
|
|
45
52
|
});
|
|
46
53
|
|
|
54
|
+
const worlds = new Map();
|
|
55
|
+
|
|
47
56
|
for (const feature of features) {
|
|
48
57
|
const tests = feature.tests;
|
|
49
58
|
test.describe(feature.feature as string, async () => {
|
|
50
|
-
const world = new supportCodeLibrary.World({
|
|
51
|
-
log,
|
|
52
|
-
attach,
|
|
53
|
-
supportCodeLibrary
|
|
54
|
-
});
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
const worldFactory = (fixtures: any) => {
|
|
61
|
+
const world = new supportCodeLibrary.World({
|
|
62
|
+
log,
|
|
63
|
+
attach,
|
|
64
|
+
supportCodeLibrary
|
|
65
|
+
});
|
|
66
|
+
Object.assign(world, fixtures);
|
|
67
|
+
worlds.set(getTestId(test.info()), world);
|
|
68
|
+
};
|
|
69
|
+
worldFactory.toString = () => { return fixture.init.toString() }
|
|
70
|
+
|
|
71
|
+
test.beforeEach('World', worldFactory);
|
|
57
72
|
|
|
58
73
|
test.beforeEach('Before Hooks', async () => {
|
|
59
|
-
const testId = test
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.find((annotation: { type: string }) => annotation.type === 'testId')
|
|
63
|
-
.description;
|
|
64
|
-
const testCase = tests.find(test => test.id === testId);
|
|
74
|
+
const testId = getTestId(test.info());
|
|
75
|
+
const world = worlds.get(testId);
|
|
76
|
+
const testCase = tests.find(test => test.id === testId)!;
|
|
65
77
|
for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
|
|
66
78
|
if (beforeHook.appliesToTestCase(testCase)) {
|
|
67
79
|
const hookName = beforeHook.name ?? 'Before';
|
|
@@ -87,6 +99,7 @@ for (const feature of features) {
|
|
|
87
99
|
{ type: 'tags', description: JSON.stringify(tag) }
|
|
88
100
|
];
|
|
89
101
|
test(testCase.name, { tag, annotation }, async () => {
|
|
102
|
+
const world = worlds.get(testCase.id);
|
|
90
103
|
const result: { status: string, error?: Error } = { status: 'passed' };
|
|
91
104
|
for (const pickleStep of testCase.steps) {
|
|
92
105
|
if (result.status !== 'passed') {
|
|
@@ -157,11 +170,9 @@ for (const feature of features) {
|
|
|
157
170
|
|
|
158
171
|
test.afterEach('After Hooks', async () => {
|
|
159
172
|
const testInfo = test.info();
|
|
160
|
-
const testId = testInfo
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
.description;
|
|
164
|
-
const testCase = tests.find(test => test.id === testId);
|
|
173
|
+
const testId = getTestId(testInfo);
|
|
174
|
+
const world = worlds.get(testId);
|
|
175
|
+
const testCase = tests.find(test => test.id === testId)!;
|
|
165
176
|
for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
|
|
166
177
|
if (afterHook.appliesToTestCase(testCase)) {
|
|
167
178
|
const hookName = afterHook.name ?? 'After';
|
|
@@ -180,6 +191,11 @@ for (const feature of features) {
|
|
|
180
191
|
}
|
|
181
192
|
});
|
|
182
193
|
|
|
194
|
+
test.afterEach('World', async () => {
|
|
195
|
+
const testId = getTestId(test.info());
|
|
196
|
+
worlds.delete(testId);
|
|
197
|
+
});
|
|
198
|
+
|
|
183
199
|
});
|
|
184
200
|
}
|
|
185
201
|
|
package/src/loader.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { join, resolve } from 'node:path';
|
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { AstBuilder, compile, GherkinClassicTokenMatcher, Parser } from '@cucumber/gherkin';
|
|
5
5
|
import { supportCodeLibraryBuilder } from '@cucumber/cucumber';
|
|
6
|
+
import type { Pickle, GherkinDocument } from '@cucumber/messages';
|
|
6
7
|
import { globSync } from 'glob';
|
|
7
8
|
import { PlaywrightWorld } from './PlaywrightWorld';
|
|
8
9
|
|
|
@@ -11,7 +12,7 @@ const builder = new AstBuilder(uuidFn);
|
|
|
11
12
|
const matcher = new GherkinClassicTokenMatcher();
|
|
12
13
|
const parser = new Parser(builder, matcher)
|
|
13
14
|
|
|
14
|
-
function duplicates(tests:
|
|
15
|
+
function duplicates(tests: readonly Pickle[]) {
|
|
15
16
|
const counts: Record<string, number> = {};
|
|
16
17
|
return tests.map(item => {
|
|
17
18
|
const name = item.name;
|
|
@@ -26,7 +27,13 @@ function duplicates(tests: any[]) {
|
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
type Feature = {
|
|
31
|
+
feature?: string;
|
|
32
|
+
gherkinDocument: GherkinDocument;
|
|
33
|
+
tests: readonly Pickle[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function loadFeatures(globPattern: string[]): Feature[] {
|
|
30
37
|
const files = globSync(globPattern);
|
|
31
38
|
return files.map(file => {
|
|
32
39
|
const filePath = resolve(file);
|
|
@@ -34,7 +41,7 @@ export function loadFeatures(globPattern: string[]) {
|
|
|
34
41
|
return {
|
|
35
42
|
feature: gherkinDocument.feature?.name,
|
|
36
43
|
gherkinDocument,
|
|
37
|
-
tests: duplicates(compile(gherkinDocument, file, uuidFn)
|
|
44
|
+
tests: duplicates(compile(gherkinDocument, file, uuidFn))
|
|
38
45
|
}
|
|
39
46
|
});
|
|
40
47
|
}
|