@uuv/playwright 3.1.0 → 3.2.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/dist/lib/runner-playwright.js +2 -1
- package/dist/reporter/uuv-playwright-reporter-helper.d.ts +5 -8
- package/dist/reporter/uuv-playwright-reporter-helper.js +54 -48
- package/dist/reporter/uuv-playwright-reporter.d.ts +1 -0
- package/dist/reporter/uuv-playwright-reporter.js +6 -2
- package/package.json +2 -2
|
@@ -94,7 +94,8 @@ class UUVCliPlaywrightRunner {
|
|
|
94
94
|
}
|
|
95
95
|
return `${targetTestFile
|
|
96
96
|
.replaceAll("uuv/e2e/", ".uuv-features-gen/")
|
|
97
|
-
.replaceAll("
|
|
97
|
+
.replaceAll("e2e/", ".features-gen/")
|
|
98
|
+
.replaceAll(/\.feature$/g, ".feature.spec.js")}`;
|
|
98
99
|
}
|
|
99
100
|
runPlaywright(options) {
|
|
100
101
|
const configFile = `${this.projectDir}/playwright.config.ts`;
|
|
@@ -16,6 +16,8 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
16
16
|
private consoleReportMap;
|
|
17
17
|
private errors;
|
|
18
18
|
private currentFeatureFile;
|
|
19
|
+
private foundConf;
|
|
20
|
+
constructor();
|
|
19
21
|
createTestRunStartedEnvelope(config: FullConfig, suite: Suite, startTimestamp: {
|
|
20
22
|
seconds: number;
|
|
21
23
|
nanos: number;
|
|
@@ -35,8 +37,8 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
35
37
|
}): void;
|
|
36
38
|
private getTestStepKey;
|
|
37
39
|
createTestCaseFinishedEnvelope(test: TestCase, result: TestResult, featureFile: string, endTimestamp: any): void;
|
|
38
|
-
private
|
|
39
|
-
private
|
|
40
|
+
private handleTestEnd;
|
|
41
|
+
private handleTestSuiteFinishedIfNeeded;
|
|
40
42
|
private addResultErrors;
|
|
41
43
|
private createTestCaseErrorAttachmentsEnvelope;
|
|
42
44
|
private initConsoleReportIfNotExists;
|
|
@@ -48,6 +50,7 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
48
50
|
nanos: number;
|
|
49
51
|
};
|
|
50
52
|
getOriginalFeatureFile(generatedFile: string): string | undefined;
|
|
53
|
+
getTestSuiteName(featureFile: string): string;
|
|
51
54
|
getCurrentRunningScenario(test: TestCase, featureFile: string): string;
|
|
52
55
|
private addError;
|
|
53
56
|
private getStatus;
|
|
@@ -68,12 +71,6 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
68
71
|
logTestEnd(testCase: TestCase, result: TestResult): void;
|
|
69
72
|
private getResultIcon;
|
|
70
73
|
private getTestCaseTitle;
|
|
71
|
-
logTeamCity(line: any): void;
|
|
72
|
-
private teamcityFlowId;
|
|
73
|
-
private teamcityFlowIdAndParentFlowId;
|
|
74
|
-
private teamcityAddName;
|
|
75
|
-
private teamcityAddDuration;
|
|
76
|
-
private teamcityAddCustomField;
|
|
77
74
|
private getTagsParameter;
|
|
78
75
|
}
|
|
79
76
|
export default UuvPlaywrightReporterHelper;
|
|
@@ -15,6 +15,7 @@ const chalk_table_1 = __importDefault(require("chalk-table"));
|
|
|
15
15
|
const uuv_custom_formatter_1 = require("./uuv-custom-formatter");
|
|
16
16
|
const tag_expressions_1 = __importDefault(require("@cucumber/tag-expressions"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const runner_commons_1 = require("@uuv/runner-commons");
|
|
18
19
|
const NANOS_IN_SECOND = 1000000000;
|
|
19
20
|
const NANOS_IN_MILLISSECOND = 1000000;
|
|
20
21
|
var GeneratedReportType;
|
|
@@ -50,6 +51,19 @@ class UuvPlaywrightReporterHelper {
|
|
|
50
51
|
consoleReportMap = new Map();
|
|
51
52
|
errors = [];
|
|
52
53
|
currentFeatureFile;
|
|
54
|
+
foundConf;
|
|
55
|
+
constructor() {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
const bddgenConfAsString = process.env.PLAYWRIGHT_BDD_CONFIGS;
|
|
59
|
+
if (bddgenConfAsString) {
|
|
60
|
+
const bddgenConf = JSON.parse(bddgenConfAsString);
|
|
61
|
+
if (Object.keys.length > 0) {
|
|
62
|
+
const foundPath = Object.keys(bddgenConf)[0];
|
|
63
|
+
this.foundConf = bddgenConf[foundPath];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
53
67
|
createTestRunStartedEnvelope(config, suite, startTimestamp) {
|
|
54
68
|
this.testDir = config.projects[0].testDir;
|
|
55
69
|
const featureFiles = this.getFeatureFiles(suite);
|
|
@@ -87,7 +101,11 @@ class UuvPlaywrightReporterHelper {
|
|
|
87
101
|
this.testCasesAndTestCasesStartedIdMap.set(test.id, testCaseStartedId);
|
|
88
102
|
this.initConsoleReportIfNotExists(featureFile);
|
|
89
103
|
}
|
|
90
|
-
|
|
104
|
+
runner_commons_1.UUVEventEmitter.getInstance().emitTestStarted({
|
|
105
|
+
testName: test.title,
|
|
106
|
+
testSuiteName: this.getTestSuiteName(featureFile),
|
|
107
|
+
testSuitelocation: featureFile
|
|
108
|
+
});
|
|
91
109
|
}
|
|
92
110
|
createTestStepStartedEnvelope(test, step, featureFile, startTimestamp) {
|
|
93
111
|
const currentQuery = this.queries.get(featureFile);
|
|
@@ -180,7 +198,7 @@ class UuvPlaywrightReporterHelper {
|
|
|
180
198
|
return `${location.file.replaceAll("\\", "_")}-${location.line}-${location.column}`;
|
|
181
199
|
}
|
|
182
200
|
createTestCaseFinishedEnvelope(test, result, featureFile, endTimestamp) {
|
|
183
|
-
this.
|
|
201
|
+
this.handleTestEnd(result, test, featureFile);
|
|
184
202
|
this.updateTestcaseStatus(featureFile, test.id, "done");
|
|
185
203
|
const currentQuery = this.queries.get(featureFile);
|
|
186
204
|
if (currentQuery) {
|
|
@@ -201,26 +219,38 @@ class UuvPlaywrightReporterHelper {
|
|
|
201
219
|
this.addResultErrors(result, test, featureFile);
|
|
202
220
|
this.createTestCaseErrorAttachmentsEnvelope(testCaseStartedId, result);
|
|
203
221
|
}
|
|
204
|
-
this.
|
|
222
|
+
this.handleTestSuiteFinishedIfNeeded(featureFile);
|
|
205
223
|
}
|
|
206
|
-
|
|
224
|
+
handleTestEnd(result, test, featureFile) {
|
|
207
225
|
switch (result.status) {
|
|
208
226
|
case "passed":
|
|
209
|
-
|
|
227
|
+
runner_commons_1.UUVEventEmitter.getInstance().emitTestFinished({
|
|
228
|
+
testName: test.title,
|
|
229
|
+
testSuiteName: this.getTestSuiteName(featureFile),
|
|
230
|
+
duration: result.duration
|
|
231
|
+
});
|
|
210
232
|
break;
|
|
211
233
|
case "failed":
|
|
212
|
-
|
|
213
|
-
|
|
234
|
+
runner_commons_1.UUVEventEmitter.getInstance().emitTestFailed({
|
|
235
|
+
testName: test.title,
|
|
236
|
+
testSuiteName: this.getTestSuiteName(featureFile),
|
|
237
|
+
duration: result.duration
|
|
238
|
+
});
|
|
214
239
|
break;
|
|
215
240
|
default:
|
|
216
|
-
|
|
241
|
+
runner_commons_1.UUVEventEmitter.getInstance().emitTestIgnored({
|
|
242
|
+
testName: test.title,
|
|
243
|
+
testSuiteName: this.getTestSuiteName(featureFile)
|
|
244
|
+
});
|
|
217
245
|
}
|
|
218
246
|
}
|
|
219
|
-
|
|
247
|
+
handleTestSuiteFinishedIfNeeded(featureFile) {
|
|
220
248
|
const featureTestCaseStatus = this.featureFileAndTestCaseStatusMap.get(featureFile);
|
|
221
249
|
if (featureTestCaseStatus) {
|
|
222
250
|
if (Object.entries(featureTestCaseStatus).find(([, value]) => value === "todo") === undefined) {
|
|
223
|
-
|
|
251
|
+
runner_commons_1.UUVEventEmitter.getInstance().emitTestSuiteFinished({
|
|
252
|
+
testSuiteName: this.getTestSuiteName(featureFile)
|
|
253
|
+
});
|
|
224
254
|
}
|
|
225
255
|
}
|
|
226
256
|
}
|
|
@@ -255,7 +285,10 @@ class UuvPlaywrightReporterHelper {
|
|
|
255
285
|
}
|
|
256
286
|
initConsoleReportIfNotExists(featureFile) {
|
|
257
287
|
if (!this.consoleReportMap.get(featureFile)) {
|
|
258
|
-
|
|
288
|
+
runner_commons_1.UUVEventEmitter.getInstance().emitTestSuiteStarted({
|
|
289
|
+
testSuiteName: this.getTestSuiteName(featureFile),
|
|
290
|
+
testSuitelocation: featureFile
|
|
291
|
+
});
|
|
259
292
|
this.consoleReportMap.set(featureFile, new ReportOfFeature());
|
|
260
293
|
}
|
|
261
294
|
}
|
|
@@ -291,24 +324,19 @@ class UuvPlaywrightReporterHelper {
|
|
|
291
324
|
};
|
|
292
325
|
}
|
|
293
326
|
getOriginalFeatureFile(generatedFile) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
// @ts-ignore
|
|
299
|
-
const projectDir = process.env.CONFIG_DIR;
|
|
300
|
-
if (bddgenConfAsString && projectDir) {
|
|
301
|
-
const bddgenConf = JSON.parse(bddgenConfAsString);
|
|
302
|
-
const foundPath = Object.keys(bddgenConf).find(key => generatedFile.startsWith(key));
|
|
303
|
-
if (foundPath) {
|
|
304
|
-
const foundConf = bddgenConf[foundPath];
|
|
305
|
-
return path_1.default.relative(process.cwd(), generatedFile
|
|
306
|
-
.replaceAll(foundConf.outputDir, foundConf.featuresRoot)
|
|
307
|
-
.replaceAll(".feature.spec.js", ".feature"));
|
|
308
|
-
}
|
|
327
|
+
if (this.foundConf) {
|
|
328
|
+
return path_1.default.relative(process.cwd(), generatedFile
|
|
329
|
+
.replaceAll(this.foundConf.outputDir, this.foundConf.featuresRoot)
|
|
330
|
+
.replaceAll(".feature.spec.js", ".feature"));
|
|
309
331
|
}
|
|
310
332
|
return;
|
|
311
333
|
}
|
|
334
|
+
getTestSuiteName(featureFile) {
|
|
335
|
+
if (this.foundConf) {
|
|
336
|
+
return path_1.default.relative(this.foundConf.featuresRoot, path_1.default.join(process.cwd(), featureFile));
|
|
337
|
+
}
|
|
338
|
+
return featureFile;
|
|
339
|
+
}
|
|
312
340
|
getCurrentRunningScenario(test, featureFile) {
|
|
313
341
|
const counter = `[${test.parent.allTests().filter(test => test.results.length > 0).length}/${test.parent.allTests().length}]`;
|
|
314
342
|
return `File ${featureFile} > Scenario ${counter} - ${test.title}`;
|
|
@@ -539,28 +567,6 @@ class UuvPlaywrightReporterHelper {
|
|
|
539
567
|
return chalk_1.default.redBright(message);
|
|
540
568
|
}
|
|
541
569
|
}
|
|
542
|
-
logTeamCity(line) {
|
|
543
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
544
|
-
// @ts-ignore
|
|
545
|
-
if (process.env.enableTeamcityLogging) {
|
|
546
|
-
console.log(line);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
teamcityFlowId(name) {
|
|
550
|
-
return "flowId='" + name.replaceAll("'", "|'") + "'";
|
|
551
|
-
}
|
|
552
|
-
teamcityFlowIdAndParentFlowId(name, parentName) {
|
|
553
|
-
return "flowId='" + name.replaceAll("'", "|'") + "' parent='" + parentName.replaceAll("'", "|'") + "'";
|
|
554
|
-
}
|
|
555
|
-
teamcityAddName(name) {
|
|
556
|
-
return "name='" + name.replaceAll("'", "|'") + "'";
|
|
557
|
-
}
|
|
558
|
-
teamcityAddDuration(result) {
|
|
559
|
-
return "duration='" + result.duration + "'";
|
|
560
|
-
}
|
|
561
|
-
teamcityAddCustomField(fieldName, value) {
|
|
562
|
-
return `${fieldName}='${value}'`;
|
|
563
|
-
}
|
|
564
570
|
getTagsParameter() {
|
|
565
571
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
566
572
|
// @ts-ignore
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FullConfig, FullResult, Reporter, Suite, TestCase, TestError, TestResult, TestStep } from "@playwright/test/reporter";
|
|
2
2
|
declare class UuvPlawrightReporter implements Reporter {
|
|
3
3
|
private helper;
|
|
4
|
+
constructor();
|
|
4
5
|
onBegin(config: FullConfig, suite: Suite): void;
|
|
5
6
|
onError?(error: TestError): void;
|
|
6
7
|
onTestBegin(test: TestCase, result: TestResult): void;
|
|
@@ -5,13 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const uuv_playwright_reporter_helper_1 = __importDefault(require("./uuv-playwright-reporter-helper"));
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const runner_commons_1 = require("@uuv/runner-commons");
|
|
8
9
|
class UuvPlawrightReporter {
|
|
9
10
|
helper = new uuv_playwright_reporter_helper_1.default();
|
|
11
|
+
constructor() {
|
|
12
|
+
runner_commons_1.UUVListenerHelper.build();
|
|
13
|
+
}
|
|
10
14
|
onBegin(config, suite) {
|
|
11
15
|
const startTimestamp = this.helper.getTimestamp();
|
|
12
16
|
// console.log(`Starting the run with ${suite.allTests().length} tests`);
|
|
13
17
|
this.helper.createTestRunStartedEnvelope(config, suite, startTimestamp);
|
|
14
|
-
|
|
18
|
+
runner_commons_1.UUVEventEmitter.getInstance().emitProgressStart();
|
|
15
19
|
console.info(chalk_1.default.yellow(`Starting the run with ${suite.allTests().length} tests`));
|
|
16
20
|
}
|
|
17
21
|
onError(error) {
|
|
@@ -66,7 +70,7 @@ class UuvPlawrightReporter {
|
|
|
66
70
|
else {
|
|
67
71
|
console.error(chalk_1.default.red(`Tests executed with status: ${result.status}`));
|
|
68
72
|
}
|
|
69
|
-
|
|
73
|
+
runner_commons_1.UUVEventEmitter.getInstance().emitProgressFinish();
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
exports.default = UuvPlawrightReporter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uuv/playwright",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "Louis Fredice NJAKO MOLOM (https://github.com/luifr10) & Stanley SERVICAL (https://github.com/stanlee974)",
|
|
6
6
|
"description": "A solution to facilitate the writing and execution of E2E tests understandable by any human being using cucumber(BDD) and playwright",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@cucumber/tag-expressions": "^6.0.0",
|
|
46
46
|
"@playwright/test": "^1.44.1",
|
|
47
|
-
"@uuv/runner-commons": "2.
|
|
47
|
+
"@uuv/runner-commons": "2.17.0",
|
|
48
48
|
"axe-core": "4.9.1",
|
|
49
49
|
"axe-playwright": "2.0.1",
|
|
50
50
|
"chalk-table": "^1.0.2",
|