@uuv/playwright 1.7.3 → 1.8.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/dist/lib/runner-playwright.d.ts +1 -1
- package/dist/lib/runner-playwright.js +15 -4
- package/dist/lib/uuv-cli.js +7 -3
- package/dist/reporter/uuv-playwright-reporter-helper.d.ts +10 -0
- package/dist/reporter/uuv-playwright-reporter-helper.js +60 -2
- package/dist/reporter/uuv-playwright-reporter.js +3 -1
- package/package.json +2 -2
|
@@ -17,4 +17,4 @@ export interface UUVPlaywrightCucumberMapItem {
|
|
|
17
17
|
generatedFile: string;
|
|
18
18
|
}
|
|
19
19
|
export declare const UUVPlaywrightCucumberMapFile = ".uuv-playwright-cucumber-map.json";
|
|
20
|
-
export declare function run(mode: "open" | "e2e", tempDir?: string, configDir?: string, generateHtmlReport?: boolean): Promise<void>;
|
|
20
|
+
export declare function run(mode: "open" | "e2e", tempDir?: string, configDir?: string, generateHtmlReport?: boolean, env?: any, targetTestFile?: string): Promise<void>;
|
|
@@ -88,7 +88,7 @@ function translateFeatures(tempDir, configDir) {
|
|
|
88
88
|
console.log(chalk_1.default.gray(`[WRITE] ${generatedFile} written successfully`));
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
function runPlaywright(mode, configDir, generateHtmlReport = false) {
|
|
91
|
+
function runPlaywright(mode, configDir, generateHtmlReport = false, env, targetTestFile) {
|
|
92
92
|
const configFile = `${configDir}/playwright.config.ts`;
|
|
93
93
|
const reportType = generateHtmlReport ? uuv_playwright_reporter_helper_1.GeneratedReportType.HTML : uuv_playwright_reporter_helper_1.GeneratedReportType.CONSOLE;
|
|
94
94
|
try {
|
|
@@ -98,7 +98,10 @@ function runPlaywright(mode, configDir, generateHtmlReport = false) {
|
|
|
98
98
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
99
99
|
// @ts-ignore
|
|
100
100
|
process.env.CONFIG_DIR = configDir;
|
|
101
|
-
|
|
101
|
+
if (env) {
|
|
102
|
+
Object.keys(env).forEach(key => process.env[key] = env[key]);
|
|
103
|
+
}
|
|
104
|
+
const command = `npx playwright test --project=chromium -c ${configFile} ${mode === "open" ? "--ui" : ""} ${getTargetTestFileForPlawright(targetTestFile)}`;
|
|
102
105
|
console.log(chalk_1.default.gray(`Running ${command}`));
|
|
103
106
|
(0, child_process_1.execSync)(command, { stdio: "inherit" });
|
|
104
107
|
}
|
|
@@ -106,14 +109,22 @@ function runPlaywright(mode, configDir, generateHtmlReport = false) {
|
|
|
106
109
|
process.exit(-1);
|
|
107
110
|
}
|
|
108
111
|
}
|
|
112
|
+
function getTargetTestFileForPlawright(targetTestFile) {
|
|
113
|
+
if (!targetTestFile) {
|
|
114
|
+
return "";
|
|
115
|
+
}
|
|
116
|
+
return targetTestFile
|
|
117
|
+
.replaceAll("uuv/e2e/", ".uuv-features-gen/uuv/e2e/")
|
|
118
|
+
.replaceAll(".feature", ".feature.spec.js");
|
|
119
|
+
}
|
|
109
120
|
async function executePreprocessor(tempDir, configDir) {
|
|
110
121
|
console.log("running preprocessor...");
|
|
111
122
|
await bddGen(tempDir);
|
|
112
123
|
translateFeatures(tempDir, configDir);
|
|
113
124
|
console.log("preprocessor executed");
|
|
114
125
|
}
|
|
115
|
-
async function run(mode, tempDir = "uuv/.features-gen/e2e", configDir = "uuv", generateHtmlReport = false) {
|
|
126
|
+
async function run(mode, tempDir = "uuv/.features-gen/e2e", configDir = "uuv", generateHtmlReport = false, env, targetTestFile) {
|
|
116
127
|
await executePreprocessor(tempDir, configDir);
|
|
117
|
-
runPlaywright(mode, configDir, generateHtmlReport);
|
|
128
|
+
runPlaywright(mode, configDir, generateHtmlReport, env, targetTestFile);
|
|
118
129
|
}
|
|
119
130
|
exports.run = run;
|
package/dist/lib/uuv-cli.js
CHANGED
|
@@ -46,10 +46,14 @@ async function main() {
|
|
|
46
46
|
function extractArgs(argv) {
|
|
47
47
|
const browser = argv.browser ? argv.browser : "chrome";
|
|
48
48
|
const env = argv.env ? JSON.parse(argv.env.replace(/'/g, "\"")) : {};
|
|
49
|
+
const targetTestFile = argv.targetTestFile ? argv.targetTestFile : null;
|
|
49
50
|
console.debug("Variables: ");
|
|
50
51
|
console.debug(` -> browser: ${browser}`);
|
|
51
52
|
console.debug(` -> env: ${JSON.stringify(env)}`);
|
|
52
|
-
|
|
53
|
+
if (targetTestFile) {
|
|
54
|
+
console.debug(` -> targetTestFile: ${targetTestFile}`);
|
|
55
|
+
}
|
|
56
|
+
return { browser, env, targetTestFile };
|
|
53
57
|
}
|
|
54
58
|
function openPlaywright(argv) {
|
|
55
59
|
// TODO Implementer les paramètres env en json
|
|
@@ -57,14 +61,14 @@ async function main() {
|
|
|
57
61
|
return (0, runner_playwright_1.run)("open", FEATURE_GEN_DIR, PROJECT_DIR);
|
|
58
62
|
}
|
|
59
63
|
function runE2ETests(argv) {
|
|
60
|
-
const { browser, env } = extractArgs(argv);
|
|
64
|
+
const { browser, env, targetTestFile } = extractArgs(argv);
|
|
61
65
|
// TODO Manage HTML Report
|
|
62
66
|
// Creating needed dirs
|
|
63
67
|
// if (!fs.existsSync(JSON_REPORT_DIR)) {
|
|
64
68
|
// fs.mkdirSync(JSON_REPORT_DIR, { recursive: true });
|
|
65
69
|
// }
|
|
66
70
|
// Running Tests
|
|
67
|
-
return (0, runner_playwright_1.run)("e2e", FEATURE_GEN_DIR, PROJECT_DIR, argv.generateHtmlReport)
|
|
71
|
+
return (0, runner_playwright_1.run)("e2e", FEATURE_GEN_DIR, PROJECT_DIR, argv.generateHtmlReport, env, targetTestFile)
|
|
68
72
|
.then(async (result) => {
|
|
69
73
|
console.log(`Status ${chalk_1.default.green("success")}`);
|
|
70
74
|
})
|
|
@@ -10,6 +10,7 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
10
10
|
testDir: string;
|
|
11
11
|
private queries;
|
|
12
12
|
envelopes: Envelope[];
|
|
13
|
+
private featureFileAndTestCaseStatusMap;
|
|
13
14
|
private testCasesAndTestCasesStartedIdMap;
|
|
14
15
|
private testCasesAndPickleIdMap;
|
|
15
16
|
private testCasesTestStepStartedIdMap;
|
|
@@ -36,6 +37,8 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
36
37
|
}): void;
|
|
37
38
|
private getTestStepKey;
|
|
38
39
|
createTestCaseFinishedEnvelope(test: TestCase, result: TestResult, featureFile: string, endTimestamp: any): void;
|
|
40
|
+
private logTeamcityTestEnd;
|
|
41
|
+
private logTeamcitySuiteFinishedIfNeeded;
|
|
39
42
|
private addResultErrors;
|
|
40
43
|
private createTestCaseErrorAttachmentsEnvelope;
|
|
41
44
|
private initConsoleReportIfNotExists;
|
|
@@ -55,6 +58,7 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
55
58
|
private loadUUVPlaywrightCucumberMap;
|
|
56
59
|
private initializeCucumberReportNdJson;
|
|
57
60
|
private populateTestCasesAndPickleIdMap;
|
|
61
|
+
private updateTestcaseStatus;
|
|
58
62
|
private generateTestStep;
|
|
59
63
|
private createStepDefinitionEnvelope;
|
|
60
64
|
private getFeatureFiles;
|
|
@@ -67,5 +71,11 @@ declare class UuvPlaywrightReporterHelper {
|
|
|
67
71
|
logTestEnd(testCase: TestCase, result: TestResult): void;
|
|
68
72
|
private getResultIcon;
|
|
69
73
|
private getTestCaseTitle;
|
|
74
|
+
logTeamCity(line: any): void;
|
|
75
|
+
private teamcityFlowId;
|
|
76
|
+
private teamcityFlowIdAndParentFlowId;
|
|
77
|
+
private teamcityAddName;
|
|
78
|
+
private teamcityAddDuration;
|
|
79
|
+
private teamcityAddCustomField;
|
|
70
80
|
}
|
|
71
81
|
export default UuvPlaywrightReporterHelper;
|
|
@@ -42,6 +42,7 @@ class UuvPlaywrightReporterHelper {
|
|
|
42
42
|
testDir;
|
|
43
43
|
queries = new Map();
|
|
44
44
|
envelopes = [];
|
|
45
|
+
featureFileAndTestCaseStatusMap = new Map();
|
|
45
46
|
testCasesAndTestCasesStartedIdMap = new Map();
|
|
46
47
|
testCasesAndPickleIdMap = new Map();
|
|
47
48
|
testCasesTestStepStartedIdMap = new Map();
|
|
@@ -87,6 +88,7 @@ class UuvPlaywrightReporterHelper {
|
|
|
87
88
|
this.testCasesAndTestCasesStartedIdMap.set(test.id, testCaseStartedId);
|
|
88
89
|
this.initConsoleReportIfNotExists(featureFile);
|
|
89
90
|
}
|
|
91
|
+
this.logTeamCity(`##teamcity[testStarted ${this.teamcityAddName(test.title)} ${this.teamcityFlowIdAndParentFlowId(test.title, featureFile)} ${this.teamcityAddCustomField("locationHint", "test://" + featureFile)} ]`);
|
|
90
92
|
}
|
|
91
93
|
createTestStepStartedEnvelope(test, step, featureFile, startTimestamp) {
|
|
92
94
|
const currentQuery = this.queries.get(featureFile);
|
|
@@ -180,6 +182,8 @@ class UuvPlaywrightReporterHelper {
|
|
|
180
182
|
return `${location.file.replaceAll("\\", "_")}-${location.line}-${location.column}`;
|
|
181
183
|
}
|
|
182
184
|
createTestCaseFinishedEnvelope(test, result, featureFile, endTimestamp) {
|
|
185
|
+
this.logTeamcityTestEnd(result, test, featureFile);
|
|
186
|
+
this.updateTestcaseStatus(featureFile, test.id, "done");
|
|
183
187
|
const currentQuery = this.queries.get(featureFile);
|
|
184
188
|
if (currentQuery) {
|
|
185
189
|
if (result.status === "skipped" || result.status === "failed") {
|
|
@@ -199,6 +203,28 @@ class UuvPlaywrightReporterHelper {
|
|
|
199
203
|
this.addResultErrors(result, test, featureFile);
|
|
200
204
|
this.createTestCaseErrorAttachmentsEnvelope(testCaseStartedId, result);
|
|
201
205
|
}
|
|
206
|
+
this.logTeamcitySuiteFinishedIfNeeded(featureFile);
|
|
207
|
+
}
|
|
208
|
+
logTeamcityTestEnd(result, test, featureFile) {
|
|
209
|
+
switch (result.status) {
|
|
210
|
+
case "passed":
|
|
211
|
+
this.logTeamCity(`##teamcity[testFinished ${this.teamcityAddName(test.title)} ${this.teamcityFlowIdAndParentFlowId(test.title, featureFile)} ${this.teamcityAddDuration(result)} ]`);
|
|
212
|
+
break;
|
|
213
|
+
case "failed":
|
|
214
|
+
this.logTeamCity(`##teamcity[testFailed ${this.teamcityAddName(test.title)} ${this.teamcityFlowIdAndParentFlowId(test.title, featureFile)} type='comparisonFailure' message='Test failed' ]`);
|
|
215
|
+
this.logTeamCity(`##teamcity[testFinished ${this.teamcityAddName(test.title)} ${this.teamcityFlowIdAndParentFlowId(test.title, featureFile)} ${this.teamcityAddDuration(result)} ]`);
|
|
216
|
+
break;
|
|
217
|
+
default:
|
|
218
|
+
this.logTeamCity(`##teamcity[testIgnored ${this.teamcityAddName(test.title)} ${this.teamcityFlowIdAndParentFlowId(test.title, featureFile)} ]`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
logTeamcitySuiteFinishedIfNeeded(featureFile) {
|
|
222
|
+
const featureTestCaseStatus = this.featureFileAndTestCaseStatusMap.get(featureFile);
|
|
223
|
+
if (featureTestCaseStatus) {
|
|
224
|
+
if (Object.entries(featureTestCaseStatus).find(([, value]) => value === "todo") === undefined) {
|
|
225
|
+
this.logTeamCity(`##teamcity[testSuiteFinished ${this.teamcityAddName(featureFile)} ${this.teamcityFlowId(featureFile)} ]`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
202
228
|
}
|
|
203
229
|
addResultErrors(result, test, featureFile) {
|
|
204
230
|
result.errors.forEach(error => {
|
|
@@ -231,6 +257,7 @@ class UuvPlaywrightReporterHelper {
|
|
|
231
257
|
}
|
|
232
258
|
initConsoleReportIfNotExists(featureFile) {
|
|
233
259
|
if (!this.consoleReportMap.get(featureFile)) {
|
|
260
|
+
this.logTeamCity(`##teamcity[testSuiteStarted ${this.teamcityAddName(featureFile)} ${this.teamcityFlowId(featureFile)} ${this.teamcityAddCustomField("locationHint", "suite://" + featureFile)} ]`);
|
|
234
261
|
this.consoleReportMap.set(featureFile, new ReportOfFeature());
|
|
235
262
|
}
|
|
236
263
|
}
|
|
@@ -316,18 +343,27 @@ class UuvPlaywrightReporterHelper {
|
|
|
316
343
|
currentEnvelopes.forEach(envelope => currentQuery.update(envelope));
|
|
317
344
|
this.queries.set(originalFile, currentQuery);
|
|
318
345
|
this.envelopes = this.envelopes.concat(currentEnvelopes);
|
|
319
|
-
this.
|
|
346
|
+
this.featureFileAndTestCaseStatusMap.set(originalFile, []);
|
|
347
|
+
this.populateTestCasesAndPickleIdMap(currentQuery, suite, featureFile, originalFile);
|
|
320
348
|
}
|
|
321
349
|
});
|
|
322
350
|
}
|
|
323
|
-
populateTestCasesAndPickleIdMap(currentQuery, suite, featureFile) {
|
|
351
|
+
populateTestCasesAndPickleIdMap(currentQuery, suite, featureFile, originalFile) {
|
|
324
352
|
const pickles = currentQuery.getPickles();
|
|
325
353
|
const featureFileTestSuite = suite.allTests()
|
|
326
354
|
.filter(testCase => testCase.location.file === featureFile);
|
|
327
355
|
featureFileTestSuite.forEach((testCase, index) => {
|
|
328
356
|
this.testCasesAndPickleIdMap.set(testCase.id, pickles[index].id);
|
|
357
|
+
this.updateTestcaseStatus(originalFile, testCase.id, "todo");
|
|
329
358
|
});
|
|
330
359
|
}
|
|
360
|
+
updateTestcaseStatus(originalFile, testCaseId, newStatus) {
|
|
361
|
+
const featureTestCaseStatus = this.featureFileAndTestCaseStatusMap.get(originalFile);
|
|
362
|
+
if (featureTestCaseStatus) {
|
|
363
|
+
featureTestCaseStatus[`${testCaseId}`] = newStatus;
|
|
364
|
+
this.featureFileAndTestCaseStatusMap.set(originalFile, featureTestCaseStatus);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
331
367
|
generateTestStep(currentQuery, test) {
|
|
332
368
|
const pickleId = this.testCasesAndPickleIdMap.get(test.id);
|
|
333
369
|
return currentQuery.getPickles()
|
|
@@ -447,5 +483,27 @@ class UuvPlaywrightReporterHelper {
|
|
|
447
483
|
const message = `${testCase.title} (${result.duration}ms)`;
|
|
448
484
|
return !testCase.ok() ? chalk_1.default.redBright(message) : chalk_1.default.gray(message);
|
|
449
485
|
}
|
|
486
|
+
logTeamCity(line) {
|
|
487
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
488
|
+
// @ts-ignore
|
|
489
|
+
if (process.env.enableTeamcityLogging) {
|
|
490
|
+
console.log(line);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
teamcityFlowId(name) {
|
|
494
|
+
return "flowId='" + name.replaceAll("'", "|'") + "'";
|
|
495
|
+
}
|
|
496
|
+
teamcityFlowIdAndParentFlowId(name, parentName) {
|
|
497
|
+
return "flowId='" + name.replaceAll("'", "|'") + "' parent='" + parentName.replaceAll("'", "|'") + "'";
|
|
498
|
+
}
|
|
499
|
+
teamcityAddName(name) {
|
|
500
|
+
return "name='" + name.replaceAll("'", "|'") + "'";
|
|
501
|
+
}
|
|
502
|
+
teamcityAddDuration(result) {
|
|
503
|
+
return "duration='" + result.duration + "'";
|
|
504
|
+
}
|
|
505
|
+
teamcityAddCustomField(fieldName, value) {
|
|
506
|
+
return `${fieldName}='${value}'`;
|
|
507
|
+
}
|
|
450
508
|
}
|
|
451
509
|
exports.default = UuvPlaywrightReporterHelper;
|
|
@@ -11,6 +11,7 @@ class UuvPlawrightReporter {
|
|
|
11
11
|
const startTimestamp = this.helper.getTimestamp();
|
|
12
12
|
// console.log(`Starting the run with ${suite.allTests().length} tests`);
|
|
13
13
|
this.helper.createTestRunStartedEnvelope(config, suite, startTimestamp);
|
|
14
|
+
this.helper.logTeamCity("##teamcity[progressStart 'Running UUV Tests']");
|
|
14
15
|
console.info(chalk_1.default.yellow(`Starting the run with ${suite.allTests().length} tests`));
|
|
15
16
|
}
|
|
16
17
|
onError(error) {
|
|
@@ -46,8 +47,8 @@ class UuvPlawrightReporter {
|
|
|
46
47
|
// console.log(`Finished test ${test.title}: ${result.status}`);
|
|
47
48
|
const featureFile = this.helper.getOriginalFeatureFile(test.location.file);
|
|
48
49
|
if (featureFile) {
|
|
49
|
-
this.helper.createTestCaseFinishedEnvelope(test, result, featureFile, endTimestamp);
|
|
50
50
|
this.helper.logTestEnd(test, result);
|
|
51
|
+
this.helper.createTestCaseFinishedEnvelope(test, result, featureFile, endTimestamp);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
async onEnd(result) {
|
|
@@ -64,6 +65,7 @@ class UuvPlawrightReporter {
|
|
|
64
65
|
else {
|
|
65
66
|
console.error(chalk_1.default.red(`Tests executed with status: ${result.status}`));
|
|
66
67
|
}
|
|
68
|
+
this.helper.logTeamCity("##teamcity[progressFinish 'Running UUV Tests']");
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
exports.default = UuvPlawrightReporter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uuv/playwright",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
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 run E2E tests written in cucumber(BDD) with playwright.",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@cucumber/cucumber": "9.3.0",
|
|
48
48
|
"@playwright/test": "1.33.0",
|
|
49
|
-
"@uuv/runner-commons": "1.6.
|
|
49
|
+
"@uuv/runner-commons": "1.6.3",
|
|
50
50
|
"axe-core": "4.7.2",
|
|
51
51
|
"axe-playwright": "1.2.3",
|
|
52
52
|
"chalk": "4.1.2",
|