@serenity-js/playwright-test 3.18.0 → 3.19.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 +26 -0
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts +3 -1
- package/lib/reporter/SerenityReporterForPlaywrightTest.d.ts.map +1 -1
- package/lib/reporter/SerenityReporterForPlaywrightTest.js +14 -6
- package/lib/reporter/SerenityReporterForPlaywrightTest.js.map +1 -1
- package/package.json +7 -7
- package/src/reporter/SerenityReporterForPlaywrightTest.ts +81 -43
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,32 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.19.0](https://github.com/serenity-js/serenity-js/compare/v3.18.1...v3.19.0) (2024-03-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **console-reporter:** fix comments ([e8b21dd](https://github.com/serenity-js/serenity-js/commit/e8b21ddb40c5addc53bdcfb212770f199f026e11))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **console-reporter:** global exception handling v1 ([cf117f1](https://github.com/serenity-js/serenity-js/commit/cf117f16ba6623e45b3bcf0d357a91539700f55b))
|
|
17
|
+
* **console-reporter:** revert to only global error handling ([a375788](https://github.com/serenity-js/serenity-js/commit/a3757886275c854c8cc6d55aedbc0d26916cde9f))
|
|
18
|
+
* **console-reporter:** test with reporter developement ([85e2bf1](https://github.com/serenity-js/serenity-js/commit/85e2bf1ad06b00aa7d917e762ce0c2e0cb964533))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [3.18.1](https://github.com/serenity-js/serenity-js/compare/v3.18.0...v3.18.1) (2024-02-23)
|
|
25
|
+
|
|
26
|
+
**Note:** Version bump only for package @serenity-js/playwright-test
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
6
32
|
# [3.18.0](https://github.com/serenity-js/serenity-js/compare/v3.17.0...v3.18.0) (2024-02-17)
|
|
7
33
|
|
|
8
34
|
**Note:** Version bump only for package @serenity-js/playwright-test
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FullConfig } from '@playwright/test';
|
|
2
|
-
import type { Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter';
|
|
2
|
+
import type { Reporter, Suite, TestCase, TestError, TestResult } from '@playwright/test/reporter';
|
|
3
3
|
import type { ClassDescription, Serenity, StageCrewMember, StageCrewMemberBuilder } from '@serenity-js/core';
|
|
4
4
|
import type { OutputStream } from '@serenity-js/core/lib/adapter';
|
|
5
5
|
import { RequirementsHierarchy } from '@serenity-js/core/lib/io';
|
|
@@ -39,6 +39,7 @@ export declare class SerenityReporterForPlaywrightTest implements Reporter {
|
|
|
39
39
|
private requirementsHierarchy;
|
|
40
40
|
private errorParser;
|
|
41
41
|
private sceneIds;
|
|
42
|
+
private unhandledError?;
|
|
42
43
|
/**
|
|
43
44
|
* @param config
|
|
44
45
|
* @param serenity
|
|
@@ -51,6 +52,7 @@ export declare class SerenityReporterForPlaywrightTest implements Reporter {
|
|
|
51
52
|
onBegin(config: FullConfig, suite: Suite): void;
|
|
52
53
|
onTestBegin(test: TestCase): void;
|
|
53
54
|
onTestEnd(test: TestCase, result: TestResult): void;
|
|
55
|
+
onError(error: TestError): void;
|
|
54
56
|
private determineScenarioOutcome;
|
|
55
57
|
private outcomeFrom;
|
|
56
58
|
private scenarioDetailsFrom;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SerenityReporterForPlaywrightTest.d.ts","sourceRoot":"","sources":["../../src/reporter/SerenityReporterForPlaywrightTest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAA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C,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI;IAyCnD,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAM/B,OAAO,CAAC,wBAAwB;IAahC,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,mBAAmB;IAqBrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B5B,OAAO,CAAC,IAAI;IAMZ,OAAO,CAAC,qBAAqB;IA2B7B,OAAO,CAAC,GAAG;IAIX,aAAa,IAAI,OAAO;CAG3B"}
|
|
@@ -40,6 +40,7 @@ class SerenityReporterForPlaywrightTest {
|
|
|
40
40
|
requirementsHierarchy;
|
|
41
41
|
errorParser = new PlaywrightErrorParser();
|
|
42
42
|
sceneIds = new Map();
|
|
43
|
+
unhandledError;
|
|
43
44
|
/**
|
|
44
45
|
* @param config
|
|
45
46
|
* @param serenity
|
|
@@ -62,7 +63,8 @@ class SerenityReporterForPlaywrightTest {
|
|
|
62
63
|
this.sceneIds.set(test.id, currentSceneId);
|
|
63
64
|
const scenario = this.scenarioDetailsFrom(test);
|
|
64
65
|
const tags = model_1.Tags.from(`${scenario.category.toString()} ${scenario.name.toString().replace(')', '')}`);
|
|
65
|
-
this.emit(new events_1.SceneStarts(currentSceneId, scenario, this.serenity.currentTime()), ...this.requirementsHierarchy
|
|
66
|
+
this.emit(new events_1.SceneStarts(currentSceneId, scenario, this.serenity.currentTime()), ...this.requirementsHierarchy
|
|
67
|
+
.requirementTagsFor(scenario.location.path, scenario.category.value)
|
|
66
68
|
.map(tag => new events_1.SceneTagged(currentSceneId, tag, this.serenity.currentTime())), new events_1.TestRunnerDetected(currentSceneId, new model_1.Name('Playwright'), this.serenity.currentTime()), ...tags.map(tag => new events_1.SceneTagged(currentSceneId, tag, this.serenity.currentTime())));
|
|
67
69
|
}
|
|
68
70
|
// TODO might be nice to support that by emitting TestStepStarted / Finished
|
|
@@ -95,6 +97,11 @@ class SerenityReporterForPlaywrightTest {
|
|
|
95
97
|
const scenarioOutcome = this.outcomeFrom(test, result);
|
|
96
98
|
this.serenity.announce(new events_1.SceneFinished(currentSceneId, this.scenarioDetailsFrom(test), this.determineScenarioOutcome(worstInteractionOutcome, scenarioOutcome), this.now()));
|
|
97
99
|
}
|
|
100
|
+
onError(error) {
|
|
101
|
+
if (!this.unhandledError) {
|
|
102
|
+
this.unhandledError = this.errorParser.errorFrom(error);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
98
105
|
determineScenarioOutcome(worstInteractionOutcome, scenarioOutcome) {
|
|
99
106
|
if (worstInteractionOutcome instanceof model_1.ExecutionFailedWithAssertionError) {
|
|
100
107
|
return worstInteractionOutcome;
|
|
@@ -123,16 +130,17 @@ class SerenityReporterForPlaywrightTest {
|
|
|
123
130
|
const [root_, browserName_, fileName, describeOrItBlockTitle, ...nestedTitles] = test.titlePath();
|
|
124
131
|
const path = new io_1.Path(test.location.file);
|
|
125
132
|
const scenarioName = nestedTitles.join(' ').trim();
|
|
126
|
-
const featureName = scenarioName
|
|
127
|
-
? describeOrItBlockTitle
|
|
128
|
-
: fileName;
|
|
133
|
+
const featureName = scenarioName ? describeOrItBlockTitle : fileName;
|
|
129
134
|
return new model_1.ScenarioDetails(new model_1.Name(scenarioName || describeOrItBlockTitle), new model_1.Category(featureName), new io_1.FileSystemLocation(path, test.location.line, test.location.column));
|
|
130
135
|
}
|
|
131
136
|
async onEnd() {
|
|
132
137
|
this.serenity.announce(new events_1.TestRunFinishes(this.serenity.currentTime()));
|
|
133
138
|
try {
|
|
134
139
|
await this.serenity.waitForNextCue();
|
|
135
|
-
|
|
140
|
+
const outcome = this.unhandledError ?
|
|
141
|
+
new model_1.ExecutionFailedWithError(this.unhandledError)
|
|
142
|
+
: new model_1.ExecutionSuccessful();
|
|
143
|
+
this.serenity.announce(new events_1.TestRunFinished(outcome, this.serenity.currentTime()));
|
|
136
144
|
}
|
|
137
145
|
catch (error) {
|
|
138
146
|
this.serenity.announce(new events_1.TestRunFinished(new model_1.ExecutionFailedWithError(error), this.serenity.currentTime()));
|
|
@@ -143,7 +151,7 @@ class SerenityReporterForPlaywrightTest {
|
|
|
143
151
|
// reporter.onStdErr(chunk, test, result)
|
|
144
152
|
// reporter.onStdOut(chunk, test, result)
|
|
145
153
|
emit(...events) {
|
|
146
|
-
events.forEach(event => {
|
|
154
|
+
events.forEach((event) => {
|
|
147
155
|
this.serenity.announce(event);
|
|
148
156
|
});
|
|
149
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SerenityReporterForPlaywrightTest.js","sourceRoot":"","sources":["../../src/reporter/SerenityReporterForPlaywrightTest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"SerenityReporterForPlaywrightTest.js","sourceRoot":"","sources":["../../src/reporter/SerenityReporterForPlaywrightTest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AASA,4CAAsF;AAGtF,qEAAuD;AACvD,yDAUsC;AACtC,iDAAwG;AAExG,uDAYqC;AAErC,mEAA4F;AA8B5F;;;;GAIG;AACH,MAAa,iCAAiC;IAerB;IACT;IAfJ,WAAW,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAC1C,QAAQ,GAA+B,IAAI,GAAG,EAAE,CAAC;IACjD,cAAc,CAAS;IAE/B;;;;;;;OAOG;IACH,YACI,MAA+C,EAC9B,WAAqB,eAAwB,EACtD,wBAA+C,IAAI,0BAAqB,CAC5E,IAAI,eAAU,CAAC,SAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAC3C;QAHgB,aAAQ,GAAR,QAAQ,CAAqC;QACtD,0BAAqB,GAArB,qBAAqB,CAE5B;QAED,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,CAAC,MAAkB,EAAE,KAAY;QACpC,IAAI,CAAC,qBAAqB,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reporter and test APIs for Playwright Test",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jan Molak",
|
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@playwright/test": "1.41.2",
|
|
49
|
-
"@serenity-js/core": "3.
|
|
50
|
-
"@serenity-js/playwright": "3.
|
|
51
|
-
"@serenity-js/rest": "3.
|
|
52
|
-
"@serenity-js/web": "3.
|
|
49
|
+
"@serenity-js/core": "3.19.0",
|
|
50
|
+
"@serenity-js/playwright": "3.19.0",
|
|
51
|
+
"@serenity-js/rest": "3.19.0",
|
|
52
|
+
"@serenity-js/web": "3.19.0",
|
|
53
53
|
"deepmerge": "4.3.1",
|
|
54
54
|
"tiny-types": "1.21.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@integration/testing-tools": "3.0.0",
|
|
58
|
-
"@types/chai": "4.3.
|
|
58
|
+
"@types/chai": "4.3.12",
|
|
59
59
|
"@types/mocha": "10.0.6",
|
|
60
60
|
"c8": "9.1.0",
|
|
61
61
|
"mocha": "10.3.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"ts-node": "10.9.2",
|
|
64
64
|
"typescript": "5.2.2"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "6bc255b85d3e74d000b1584a64e460cc5adc1e23"
|
|
67
67
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { FullConfig } from '@playwright/test';
|
|
2
|
-
import type { Reporter, Suite, TestCase, TestError, TestResult } from '@playwright/test/reporter';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
2
|
+
import type { Reporter, Suite, TestCase, TestError, TestResult, } from '@playwright/test/reporter';
|
|
3
|
+
import type {
|
|
4
|
+
ClassDescription,
|
|
5
|
+
Serenity,
|
|
6
|
+
StageCrewMember,
|
|
7
|
+
StageCrewMemberBuilder,
|
|
8
|
+
Timestamp,
|
|
9
|
+
} from '@serenity-js/core';
|
|
10
|
+
import { LogicError, serenity as reporterSerenityInstance, } from '@serenity-js/core';
|
|
5
11
|
import type { OutputStream } from '@serenity-js/core/lib/adapter';
|
|
6
12
|
import type { DomainEvent } from '@serenity-js/core/lib/events';
|
|
7
13
|
import * as events from '@serenity-js/core/lib/events';
|
|
@@ -16,7 +22,7 @@ import {
|
|
|
16
22
|
TestRunnerDetected,
|
|
17
23
|
TestRunStarts
|
|
18
24
|
} from '@serenity-js/core/lib/events';
|
|
19
|
-
import { FileSystem, FileSystemLocation, Path, RequirementsHierarchy } from '@serenity-js/core/lib/io';
|
|
25
|
+
import { FileSystem, FileSystemLocation, Path, RequirementsHierarchy, } from '@serenity-js/core/lib/io';
|
|
20
26
|
import type { CorrelationId, Outcome, Tag } from '@serenity-js/core/lib/model';
|
|
21
27
|
import {
|
|
22
28
|
ArbitraryTag,
|
|
@@ -40,7 +46,6 @@ import { SERENITY_JS_DOMAIN_EVENTS_ATTACHMENT_CONTENT_TYPE } from './PlaywrightA
|
|
|
40
46
|
* See {@apilink SerenityOptions} for usage examples.
|
|
41
47
|
*/
|
|
42
48
|
export interface SerenityReporterForPlaywrightTestConfig {
|
|
43
|
-
|
|
44
49
|
/**
|
|
45
50
|
* A list of {@apilink StageCrewMemberBuilder|StageCrewMemberBuilders} or {@apilink StageCrewMember|StageCrewMembers}
|
|
46
51
|
* to be instantiated in Playwright Test reporter process and notified of {@apilink DomainEvent|DomainEvents} that occur during the scenario execution.
|
|
@@ -69,9 +74,9 @@ export interface SerenityReporterForPlaywrightTestConfig {
|
|
|
69
74
|
* Serenity/JS {@apilink StageCrewMember|stage crew members}.
|
|
70
75
|
*/
|
|
71
76
|
export class SerenityReporterForPlaywrightTest implements Reporter {
|
|
72
|
-
|
|
73
77
|
private errorParser = new PlaywrightErrorParser();
|
|
74
78
|
private sceneIds: Map<string, CorrelationId> = new Map();
|
|
79
|
+
private unhandledError?: Error;
|
|
75
80
|
|
|
76
81
|
/**
|
|
77
82
|
* @param config
|
|
@@ -84,33 +89,45 @@ export class SerenityReporterForPlaywrightTest implements Reporter {
|
|
|
84
89
|
constructor(
|
|
85
90
|
config: SerenityReporterForPlaywrightTestConfig,
|
|
86
91
|
private readonly serenity: Serenity = reporterSerenityInstance,
|
|
87
|
-
private requirementsHierarchy: RequirementsHierarchy = new RequirementsHierarchy(
|
|
92
|
+
private requirementsHierarchy: RequirementsHierarchy = new RequirementsHierarchy(
|
|
93
|
+
new FileSystem(Path.from(process.cwd())),
|
|
94
|
+
),
|
|
88
95
|
) {
|
|
89
96
|
this.serenity.configure(config);
|
|
90
97
|
}
|
|
91
98
|
|
|
92
99
|
onBegin(config: FullConfig, suite: Suite): void {
|
|
93
|
-
this.requirementsHierarchy = new RequirementsHierarchy(
|
|
100
|
+
this.requirementsHierarchy = new RequirementsHierarchy(
|
|
101
|
+
new FileSystem(Path.from(config.rootDir)),
|
|
102
|
+
);
|
|
94
103
|
|
|
95
104
|
this.serenity.announce(new TestRunStarts(this.now()));
|
|
96
105
|
}
|
|
97
106
|
|
|
98
107
|
onTestBegin(test: TestCase): void {
|
|
99
|
-
|
|
100
108
|
const currentSceneId = this.serenity.assignNewSceneId();
|
|
101
109
|
|
|
102
110
|
this.sceneIds.set(test.id, currentSceneId);
|
|
103
111
|
|
|
104
112
|
const scenario = this.scenarioDetailsFrom(test);
|
|
105
|
-
|
|
106
|
-
const tags: Tag[] = Tags.from(
|
|
113
|
+
|
|
114
|
+
const tags: Tag[] = Tags.from(
|
|
115
|
+
`${ scenario.category.toString() } ${ scenario.name.toString().replace(')', '') }`,
|
|
116
|
+
);
|
|
107
117
|
|
|
108
118
|
this.emit(
|
|
109
119
|
new SceneStarts(currentSceneId, scenario, this.serenity.currentTime()),
|
|
110
120
|
|
|
111
|
-
...this.requirementsHierarchy
|
|
121
|
+
...this.requirementsHierarchy
|
|
122
|
+
.requirementTagsFor(scenario.location.path, scenario.category.value)
|
|
112
123
|
.map(tag => new SceneTagged(currentSceneId, tag, this.serenity.currentTime())),
|
|
113
|
-
|
|
124
|
+
|
|
125
|
+
new TestRunnerDetected(
|
|
126
|
+
currentSceneId,
|
|
127
|
+
new Name('Playwright'),
|
|
128
|
+
this.serenity.currentTime(),
|
|
129
|
+
),
|
|
130
|
+
|
|
114
131
|
...tags.map(tag => new SceneTagged(currentSceneId, tag, this.serenity.currentTime())),
|
|
115
132
|
);
|
|
116
133
|
}
|
|
@@ -125,7 +142,6 @@ export class SerenityReporterForPlaywrightTest implements Reporter {
|
|
|
125
142
|
// }
|
|
126
143
|
|
|
127
144
|
onTestEnd(test: TestCase, result: TestResult): void {
|
|
128
|
-
|
|
129
145
|
this.announceRetryIfNeeded(test, result);
|
|
130
146
|
|
|
131
147
|
const currentSceneId = this.sceneIds.get(test.id);
|
|
@@ -162,11 +178,20 @@ export class SerenityReporterForPlaywrightTest implements Reporter {
|
|
|
162
178
|
this.scenarioDetailsFrom(test),
|
|
163
179
|
this.determineScenarioOutcome(worstInteractionOutcome, scenarioOutcome),
|
|
164
180
|
this.now(),
|
|
165
|
-
)
|
|
181
|
+
),
|
|
166
182
|
);
|
|
167
183
|
}
|
|
168
184
|
|
|
169
|
-
|
|
185
|
+
onError(error: TestError): void {
|
|
186
|
+
if (!this.unhandledError) {
|
|
187
|
+
this.unhandledError = this.errorParser.errorFrom(error);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private determineScenarioOutcome(
|
|
192
|
+
worstInteractionOutcome: Outcome,
|
|
193
|
+
scenarioOutcome: Outcome,
|
|
194
|
+
): Outcome {
|
|
170
195
|
if (worstInteractionOutcome instanceof ExecutionFailedWithAssertionError) {
|
|
171
196
|
return worstInteractionOutcome;
|
|
172
197
|
}
|
|
@@ -177,7 +202,6 @@ export class SerenityReporterForPlaywrightTest implements Reporter {
|
|
|
177
202
|
}
|
|
178
203
|
|
|
179
204
|
private outcomeFrom(test: TestCase, result: TestResult): Outcome {
|
|
180
|
-
|
|
181
205
|
const outcome = test.outcome();
|
|
182
206
|
|
|
183
207
|
if (outcome === 'skipped') {
|
|
@@ -185,39 +209,42 @@ export class SerenityReporterForPlaywrightTest implements Reporter {
|
|
|
185
209
|
}
|
|
186
210
|
|
|
187
211
|
if (outcome === 'unexpected' && result.status === 'passed') {
|
|
188
|
-
return new ExecutionFailedWithError(
|
|
212
|
+
return new ExecutionFailedWithError(
|
|
213
|
+
new LogicError(`Scenario expected to fail, but ${ result.status }`),
|
|
214
|
+
);
|
|
189
215
|
}
|
|
190
216
|
|
|
191
|
-
if (['failed', 'interrupted', 'timedOut'].includes(result.status)) {
|
|
192
|
-
|
|
217
|
+
if ([ 'failed', 'interrupted', 'timedOut' ].includes(result.status)) {
|
|
193
218
|
if (test.retries > result.retry) {
|
|
194
219
|
return new ExecutionIgnored(this.errorParser.errorFrom(result.error));
|
|
195
220
|
}
|
|
196
221
|
|
|
197
|
-
return new ExecutionFailedWithError(
|
|
222
|
+
return new ExecutionFailedWithError(
|
|
223
|
+
this.errorParser.errorFrom(result.error),
|
|
224
|
+
);
|
|
198
225
|
}
|
|
199
226
|
|
|
200
227
|
return new ExecutionSuccessful();
|
|
201
228
|
}
|
|
202
229
|
|
|
203
230
|
private scenarioDetailsFrom(test: TestCase) {
|
|
204
|
-
const [
|
|
231
|
+
const [
|
|
232
|
+
root_,
|
|
233
|
+
browserName_,
|
|
234
|
+
fileName,
|
|
235
|
+
describeOrItBlockTitle,
|
|
236
|
+
...nestedTitles
|
|
237
|
+
] = test.titlePath();
|
|
205
238
|
|
|
206
239
|
const path = new Path(test.location.file);
|
|
207
240
|
const scenarioName = nestedTitles.join(' ').trim();
|
|
208
241
|
|
|
209
|
-
const featureName = scenarioName
|
|
210
|
-
? describeOrItBlockTitle
|
|
211
|
-
: fileName;
|
|
242
|
+
const featureName = scenarioName ? describeOrItBlockTitle : fileName;
|
|
212
243
|
|
|
213
244
|
return new ScenarioDetails(
|
|
214
245
|
new Name(scenarioName || describeOrItBlockTitle),
|
|
215
246
|
new Category(featureName),
|
|
216
|
-
new FileSystemLocation(
|
|
217
|
-
path,
|
|
218
|
-
test.location.line,
|
|
219
|
-
test.location.column,
|
|
220
|
-
),
|
|
247
|
+
new FileSystemLocation(path, test.location.line, test.location.column),
|
|
221
248
|
);
|
|
222
249
|
}
|
|
223
250
|
|
|
@@ -226,10 +253,24 @@ export class SerenityReporterForPlaywrightTest implements Reporter {
|
|
|
226
253
|
|
|
227
254
|
try {
|
|
228
255
|
await this.serenity.waitForNextCue();
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
256
|
+
|
|
257
|
+
const outcome = this.unhandledError ?
|
|
258
|
+
new ExecutionFailedWithError(this.unhandledError)
|
|
259
|
+
: new ExecutionSuccessful();
|
|
260
|
+
|
|
261
|
+
this.serenity.announce(
|
|
262
|
+
new TestRunFinished(
|
|
263
|
+
outcome,
|
|
264
|
+
this.serenity.currentTime(),
|
|
265
|
+
),
|
|
266
|
+
);
|
|
267
|
+
} catch (error) {
|
|
268
|
+
this.serenity.announce(
|
|
269
|
+
new TestRunFinished(
|
|
270
|
+
new ExecutionFailedWithError(error),
|
|
271
|
+
this.serenity.currentTime(),
|
|
272
|
+
),
|
|
273
|
+
);
|
|
233
274
|
throw error;
|
|
234
275
|
}
|
|
235
276
|
}
|
|
@@ -239,8 +280,8 @@ export class SerenityReporterForPlaywrightTest implements Reporter {
|
|
|
239
280
|
// reporter.onStdOut(chunk, test, result)
|
|
240
281
|
|
|
241
282
|
private emit(...events: DomainEvent[]): void {
|
|
242
|
-
events.forEach(event => {
|
|
243
|
-
this.serenity.announce(event)
|
|
283
|
+
events.forEach((event) => {
|
|
284
|
+
this.serenity.announce(event);
|
|
244
285
|
});
|
|
245
286
|
}
|
|
246
287
|
|
|
@@ -252,13 +293,10 @@ export class SerenityReporterForPlaywrightTest implements Reporter {
|
|
|
252
293
|
const currentSceneId = this.sceneIds.get(test.id);
|
|
253
294
|
|
|
254
295
|
this.emit(
|
|
255
|
-
new RetryableSceneDetected(
|
|
256
|
-
currentSceneId,
|
|
257
|
-
this.now(),
|
|
258
|
-
),
|
|
296
|
+
new RetryableSceneDetected(currentSceneId, this.now()),
|
|
259
297
|
new SceneTagged(
|
|
260
298
|
currentSceneId,
|
|
261
|
-
new ArbitraryTag('retried'),
|
|
299
|
+
new ArbitraryTag('retried'), // todo: replace with a dedicated tag
|
|
262
300
|
this.now(),
|
|
263
301
|
),
|
|
264
302
|
);
|
|
@@ -290,14 +328,14 @@ class PlaywrightErrorParser {
|
|
|
290
328
|
);
|
|
291
329
|
|
|
292
330
|
public errorFrom(testError: TestError): Error {
|
|
293
|
-
|
|
294
331
|
const message = testError.message && PlaywrightErrorParser.stripAsciiFrom(testError.message);
|
|
332
|
+
|
|
295
333
|
let stack = testError.stack && PlaywrightErrorParser.stripAsciiFrom(testError.stack);
|
|
296
334
|
|
|
297
335
|
// TODO: Do I need to process it?
|
|
298
336
|
// const value = testError.value;
|
|
299
337
|
|
|
300
|
-
const prologue = `Error: ${message}`;
|
|
338
|
+
const prologue = `Error: ${ message }`;
|
|
301
339
|
if (stack && message && stack.startsWith(prologue)) {
|
|
302
340
|
stack = stack.slice(prologue.length);
|
|
303
341
|
}
|