@qavajs/playwright-runner-adapter 1.1.0 → 1.1.1
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 +24 -9
- package/adapter/cucumber.spec.js.map +1 -1
- package/package.json +5 -5
- package/src/cucumber.spec.ts +29 -12
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,9 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
|
|
10
10
|
:pencil: - chore
|
|
11
11
|
:microscope: - experimental
|
|
12
12
|
|
|
13
|
+
## [1.1.1]
|
|
14
|
+
- :beetle: fixed issue with After hooks execution in case of failed test
|
|
15
|
+
|
|
13
16
|
## [1.1.0]
|
|
14
17
|
- :rocket: improved BeforeStep/AfterStep logging
|
|
15
18
|
- :beetle: fixed BeforeAll/AfterAll behavior
|
package/adapter/cucumber.spec.js
CHANGED
|
@@ -13,6 +13,23 @@ function attach(body, details) {
|
|
|
13
13
|
}
|
|
14
14
|
const fixture = new supportCodeLibrary.World({});
|
|
15
15
|
const test = fixture.test;
|
|
16
|
+
const stepHandler = test.expect.extend({
|
|
17
|
+
async execute(fn) {
|
|
18
|
+
try {
|
|
19
|
+
await fn();
|
|
20
|
+
return {
|
|
21
|
+
pass: true,
|
|
22
|
+
message: () => ''
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
return {
|
|
27
|
+
pass: false,
|
|
28
|
+
message: () => e.message,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
16
33
|
for (const beforeAllHook of supportCodeLibrary.beforeTestRunHookDefinitions) {
|
|
17
34
|
test.beforeAll(() => beforeAllHook.code.apply({}));
|
|
18
35
|
}
|
|
@@ -29,6 +46,7 @@ for (const feature of features) {
|
|
|
29
46
|
const tag = testCase.tags.map((tag) => tag.name);
|
|
30
47
|
test(testCase.name, { tag }, async () => {
|
|
31
48
|
var _a, _b;
|
|
49
|
+
const testInfo = test.info();
|
|
32
50
|
const result = { status: 'passed' };
|
|
33
51
|
for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
|
|
34
52
|
if (beforeHook.appliesToTestCase(testCase)) {
|
|
@@ -39,6 +57,9 @@ for (const feature of features) {
|
|
|
39
57
|
}
|
|
40
58
|
}
|
|
41
59
|
for (const pickleStep of testCase.steps) {
|
|
60
|
+
if (testInfo.error) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
42
63
|
await test.step(pickleStep.text, async () => {
|
|
43
64
|
for (const beforeStep of supportCodeLibrary.beforeTestStepHookDefinitions) {
|
|
44
65
|
if (beforeStep.appliesToTestCase(testCase)) {
|
|
@@ -62,13 +83,9 @@ for (const feature of features) {
|
|
|
62
83
|
},
|
|
63
84
|
world
|
|
64
85
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
catch (err) {
|
|
69
|
-
result.status = 'failed';
|
|
70
|
-
result.error = err;
|
|
71
|
-
}
|
|
86
|
+
await stepHandler
|
|
87
|
+
.soft(() => step.code.apply(world, parameters), 'Step')
|
|
88
|
+
.execute();
|
|
72
89
|
for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
|
|
73
90
|
if (afterStep.appliesToTestCase(testCase)) {
|
|
74
91
|
await test.step('After Step', () => afterStep.code.apply(world, [{
|
|
@@ -78,8 +95,6 @@ for (const feature of features) {
|
|
|
78
95
|
}]));
|
|
79
96
|
}
|
|
80
97
|
}
|
|
81
|
-
if (result.error)
|
|
82
|
-
throw result.error;
|
|
83
98
|
});
|
|
84
99
|
}
|
|
85
100
|
for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cucumber.spec.js","sourceRoot":"","sources":["../src/cucumber.spec.ts"],"names":[],"mappings":";;AAAA,qCAAgC;AAEhC,MAAM,EAAE,QAAQ,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|
{
|
|
2
2
|
"name": "@qavajs/playwright-runner-adapter",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "adapter for playwright test runner",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc",
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@cucumber/gherkin": "^30.0.4",
|
|
14
|
-
"glob": "^11.0.
|
|
14
|
+
"glob": "^11.0.1"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@cucumber/cucumber": "^11.
|
|
17
|
+
"@cucumber/cucumber": "^11.2.0",
|
|
18
18
|
"@playwright/test": "^1.49.1",
|
|
19
|
-
"@types/node": "^22.10.
|
|
20
|
-
"typescript": "^5.7.
|
|
19
|
+
"@types/node": "^22.10.6",
|
|
20
|
+
"typescript": "^5.7.3"
|
|
21
21
|
}
|
|
22
22
|
}
|
package/src/cucumber.spec.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { load } from './loader';
|
|
2
2
|
|
|
3
|
-
const { features, supportCodeLibrary
|
|
3
|
+
const { features, supportCodeLibrary} = load();
|
|
4
4
|
|
|
5
5
|
function log(data: any) {
|
|
6
6
|
console.log(data);
|
|
@@ -9,12 +9,29 @@ function log(data: any) {
|
|
|
9
9
|
function attach(this: { test: any }, body: any, details: any) {
|
|
10
10
|
const fileName = details.fileName ?? 'attachment';
|
|
11
11
|
const contentType = details.mediaType ?? 'text/plain';
|
|
12
|
-
this.test.info().attach(fileName, {
|
|
12
|
+
this.test.info().attach(fileName, {body, contentType});
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const fixture = new supportCodeLibrary.World({});
|
|
16
16
|
const test = fixture.test;
|
|
17
17
|
|
|
18
|
+
const stepHandler = test.expect.extend({
|
|
19
|
+
async execute(fn: () => Promise<any>) {
|
|
20
|
+
try {
|
|
21
|
+
await fn();
|
|
22
|
+
return {
|
|
23
|
+
pass: true,
|
|
24
|
+
message: () => ''
|
|
25
|
+
}
|
|
26
|
+
} catch (e: any) {
|
|
27
|
+
return {
|
|
28
|
+
pass: false,
|
|
29
|
+
message: () => e.message,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
18
35
|
for (const beforeAllHook of supportCodeLibrary.beforeTestRunHookDefinitions) {
|
|
19
36
|
test.beforeAll(() => beforeAllHook.code.apply({}));
|
|
20
37
|
}
|
|
@@ -32,7 +49,8 @@ for (const feature of features) {
|
|
|
32
49
|
|
|
33
50
|
for (const testCase of tests) {
|
|
34
51
|
const tag = testCase.tags.map((tag: { name: string }) => tag.name);
|
|
35
|
-
test(testCase.name, {
|
|
52
|
+
test(testCase.name, {tag}, async () => {
|
|
53
|
+
const testInfo = test.info();
|
|
36
54
|
const result: { status: string, error?: any } = { status: 'passed' };
|
|
37
55
|
for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
|
|
38
56
|
if (beforeHook.appliesToTestCase(testCase)) {
|
|
@@ -43,6 +61,9 @@ for (const feature of features) {
|
|
|
43
61
|
}
|
|
44
62
|
}
|
|
45
63
|
for (const pickleStep of testCase.steps) {
|
|
64
|
+
if (testInfo.error) {
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
46
67
|
await test.step(pickleStep.text, async () => {
|
|
47
68
|
for (const beforeStep of supportCodeLibrary.beforeTestStepHookDefinitions) {
|
|
48
69
|
if (beforeStep.appliesToTestCase(testCase)) {
|
|
@@ -56,20 +77,17 @@ for (const feature of features) {
|
|
|
56
77
|
.filter(stepDefinition => stepDefinition.matchesStepName(pickleStep.text));
|
|
57
78
|
if (steps.length === 0) throw new Error(`Step '${pickleStep.text}' is not defined`);
|
|
58
79
|
if (steps.length > 1) throw new Error(`'${pickleStep.text}' matches multiple step definitions`);
|
|
59
|
-
const [
|
|
60
|
-
const {
|
|
80
|
+
const [step] = steps;
|
|
81
|
+
const {parameters} = await step.getInvocationParameters({
|
|
61
82
|
step: {
|
|
62
83
|
text: pickleStep.text,
|
|
63
84
|
argument: pickleStep.argument
|
|
64
85
|
},
|
|
65
86
|
world
|
|
66
87
|
} as any);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
result.status = 'failed';
|
|
71
|
-
result.error = err;
|
|
72
|
-
}
|
|
88
|
+
await stepHandler
|
|
89
|
+
.soft(() => step.code.apply(world, parameters), 'Step')
|
|
90
|
+
.execute();
|
|
73
91
|
for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
|
|
74
92
|
if (afterStep.appliesToTestCase(testCase)) {
|
|
75
93
|
await test.step('After Step', () => afterStep.code.apply(world, [{
|
|
@@ -79,7 +97,6 @@ for (const feature of features) {
|
|
|
79
97
|
}]));
|
|
80
98
|
}
|
|
81
99
|
}
|
|
82
|
-
if (result.error) throw result.error;
|
|
83
100
|
});
|
|
84
101
|
}
|
|
85
102
|
for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
|