@qavajs/cypress-runner-adapter 1.4.0 → 1.4.2
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
CHANGED
|
@@ -14,6 +14,14 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
|
|
14
14
|
|
|
15
15
|
:microscope: - experimental
|
|
16
16
|
|
|
17
|
+
## [1.4.2]
|
|
18
|
+
- :pencil: updated to cypress 15.7.0
|
|
19
|
+
- :pencil: updated to gherkin to 37.0.0
|
|
20
|
+
|
|
21
|
+
## [1.4.1]
|
|
22
|
+
- :beetle: fixed `result` property in `After` and `AfterStep` hooks
|
|
23
|
+
- :rocket: added workaround to complete `AfterStep` hook in case of step fail
|
|
24
|
+
|
|
17
25
|
## [1.4.0]
|
|
18
26
|
- :rocket: added `Template` utility function
|
|
19
27
|
```typescript
|
|
@@ -46,8 +46,20 @@ module.exports = function makeMochaTest(tests) {
|
|
|
46
46
|
const world = new supportCodeLibrary.World();
|
|
47
47
|
world.executeStep = executeStepByText;
|
|
48
48
|
let skip = false;
|
|
49
|
-
let
|
|
49
|
+
let status = 'passed';
|
|
50
|
+
let duration = 0;
|
|
51
|
+
let exception;
|
|
52
|
+
let message;
|
|
50
53
|
afterEach(function () {
|
|
54
|
+
if (this.currentTest.state !== 'passed') {
|
|
55
|
+
skip = true;
|
|
56
|
+
}
|
|
57
|
+
duration += this.currentTest.duration;
|
|
58
|
+
if (this.currentTest.state === 'failed') {
|
|
59
|
+
status = this.currentTest.state;
|
|
60
|
+
exception = this.currentTest.err;
|
|
61
|
+
message = this.currentTest.err?.message;
|
|
62
|
+
}
|
|
51
63
|
if (this.step) {
|
|
52
64
|
for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
|
|
53
65
|
if (afterStep.appliesToTestCase(this.step)) {
|
|
@@ -55,15 +67,16 @@ module.exports = function makeMochaTest(tests) {
|
|
|
55
67
|
pickle: test,
|
|
56
68
|
pickleStep: this.step,
|
|
57
69
|
gherkinDocument: tests,
|
|
58
|
-
result:
|
|
70
|
+
result: {
|
|
71
|
+
duration,
|
|
72
|
+
status,
|
|
73
|
+
exception,
|
|
74
|
+
message
|
|
75
|
+
}
|
|
59
76
|
}]);
|
|
60
77
|
}
|
|
61
78
|
}
|
|
62
79
|
}
|
|
63
|
-
if (this.currentTest.state !== 'passed') {
|
|
64
|
-
skip = true;
|
|
65
|
-
}
|
|
66
|
-
result = this.currentTest.state;
|
|
67
80
|
});
|
|
68
81
|
for (const beforeTest of supportCodeLibrary.beforeTestCaseHookDefinitions) {
|
|
69
82
|
if (beforeTest.appliesToTestCase(test)) {
|
|
@@ -96,9 +109,15 @@ module.exports = function makeMochaTest(tests) {
|
|
|
96
109
|
for (const afterTest of supportCodeLibrary.afterTestCaseHookDefinitions) {
|
|
97
110
|
if (afterTest.appliesToTestCase(test)) {
|
|
98
111
|
it(afterTest.name, function () {
|
|
112
|
+
this.step = null;
|
|
99
113
|
afterTest.code.apply(world, [{
|
|
100
114
|
pickle: test,
|
|
101
|
-
result
|
|
115
|
+
result: {
|
|
116
|
+
duration,
|
|
117
|
+
status,
|
|
118
|
+
exception,
|
|
119
|
+
message
|
|
120
|
+
},
|
|
102
121
|
gherkinDocument: tests,
|
|
103
122
|
willBeRetried: false
|
|
104
123
|
}]);
|
|
@@ -12,13 +12,22 @@ module.exports = function makeMochaTest(tests) {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
function getResult(currentTest) {
|
|
16
|
+
return {
|
|
17
|
+
duration: currentTest.duration,
|
|
18
|
+
message: currentTest.err?.message,
|
|
19
|
+
status: currentTest.state,
|
|
20
|
+
exception: currentTest.err
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
function executeStepByText(text, argument) {
|
|
16
25
|
const steps = supportCodeLibrary.stepDefinitions
|
|
17
26
|
.filter(stepDefinition => stepDefinition.matchesStepName(text));
|
|
18
27
|
if (steps.length === 0) throw new Error(`Step '${text}' is not defined`);
|
|
19
28
|
if (steps.length > 1) throw new Error(`Step '${text}' matches multiple step definitions`);
|
|
20
|
-
const [
|
|
21
|
-
const {
|
|
29
|
+
const [step] = steps;
|
|
30
|
+
const {parameters} = step.getInvocationParameters({
|
|
22
31
|
step: {text, argument},
|
|
23
32
|
world: this
|
|
24
33
|
});
|
|
@@ -75,15 +84,29 @@ module.exports = function makeMochaTest(tests) {
|
|
|
75
84
|
}
|
|
76
85
|
});
|
|
77
86
|
|
|
78
|
-
afterEach(
|
|
87
|
+
afterEach(function () {
|
|
79
88
|
const test = findTest(tests, this.currentTest.title);
|
|
80
89
|
const world = this.world;
|
|
90
|
+
const result = getResult(this.currentTest);
|
|
91
|
+
// corner case to complete AfterStep if test is failed
|
|
92
|
+
if (result.status === 'failed' && this.step) {
|
|
93
|
+
for (const afterStep of supportCodeLibrary.afterTestStepHookDefinitions) {
|
|
94
|
+
if (afterStep.appliesToTestCase(this.step)) {
|
|
95
|
+
afterStep.code.apply(world, [{
|
|
96
|
+
pickle: test,
|
|
97
|
+
pickleStep: this.step,
|
|
98
|
+
gherkinDocument: tests,
|
|
99
|
+
result
|
|
100
|
+
}]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
81
104
|
for (const afterTest of supportCodeLibrary.afterTestCaseHookDefinitions) {
|
|
82
105
|
if (afterTest.appliesToTestCase(test)) {
|
|
83
106
|
runStep(afterTest.name, function () {
|
|
84
107
|
afterTest.code.apply(world, [{
|
|
85
108
|
pickle: test,
|
|
86
|
-
result
|
|
109
|
+
result,
|
|
87
110
|
gherkinDocument: tests,
|
|
88
111
|
willBeRetried: false
|
|
89
112
|
}]);
|
|
@@ -99,7 +122,7 @@ module.exports = function makeMochaTest(tests) {
|
|
|
99
122
|
const stepName = keyword(step) + ': ' + step.text;
|
|
100
123
|
runStep(stepName, function () {
|
|
101
124
|
this.step = step;
|
|
102
|
-
|
|
125
|
+
const result = { status: 'passed', duration: 0 };
|
|
103
126
|
for (const beforeStep of supportCodeLibrary.beforeTestStepHookDefinitions) {
|
|
104
127
|
if (beforeStep.appliesToTestCase(step)) {
|
|
105
128
|
beforeStep.code.apply(world, [{
|
|
@@ -116,7 +139,7 @@ module.exports = function makeMochaTest(tests) {
|
|
|
116
139
|
pickle: test,
|
|
117
140
|
pickleStep: this.step,
|
|
118
141
|
gherkinDocument: tests,
|
|
119
|
-
result
|
|
142
|
+
result
|
|
120
143
|
}]);
|
|
121
144
|
}
|
|
122
145
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qavajs/cypress-runner-adapter",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"debug": "cypress open --config-file test/cypress.config.js",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"homepage": "https://qavajs.github.io/docs/intro",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@cucumber/cucumber-expressions": "^18.0.1",
|
|
26
|
-
"@cucumber/gherkin": "^
|
|
26
|
+
"@cucumber/gherkin": "^37.0.0",
|
|
27
27
|
"@cucumber/tag-expressions": "^8.0.0",
|
|
28
|
-
"@cypress/webpack-preprocessor": "^7.0.
|
|
28
|
+
"@cypress/webpack-preprocessor": "^7.0.2",
|
|
29
29
|
"fs-extra": "^11.3.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"cypress": "^15.
|
|
32
|
+
"cypress": "^15.7.0"
|
|
33
33
|
},
|
|
34
34
|
"keywords": [
|
|
35
35
|
"cypress",
|