@uuv/cypress 2.15.1 → 2.17.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
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# [2.17.0](https://github.com/Orange-OpenSource/uuv/compare/runner-cypress-v2.16.0...runner-cypress-v2.17.0) (2024-05-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **runner-playwright:** update dependency typescript to v5 ([05eaf55](https://github.com/Orange-OpenSource/uuv/commit/05eaf55924ef481abe9f9442c33458b1f2d4bb02))
|
|
7
|
+
* update package-lock for update dependency typescript to v5 ([f058481](https://github.com/Orange-OpenSource/uuv/commit/f058481e2ae75ba91e708a5c4dd8ce16c0f1a04f))
|
|
8
|
+
|
|
9
|
+
# [2.16.0](https://github.com/Orange-OpenSource/uuv/compare/runner-cypress-v2.15.1...runner-cypress-v2.16.0) (2024-04-22)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* (refactor) introduce uuv-cli engine from runner-commons, [#576](https://github.com/Orange-OpenSource/uuv/issues/576) ([6de2feb](https://github.com/Orange-OpenSource/uuv/commit/6de2feb2b2d74eddf1244694dfb7d697af28baf8))
|
|
15
|
+
* add unit tests for uuv-cli implementations, [#576](https://github.com/Orange-OpenSource/uuv/issues/576) ([7e67f13](https://github.com/Orange-OpenSource/uuv/commit/7e67f13b9929577162bce84c5e8b5c08a4396a09))
|
|
16
|
+
|
|
1
17
|
## [2.15.1](https://github.com/Orange-OpenSource/uuv/compare/runner-cypress-v2.15.0...runner-cypress-v2.15.1) (2024-04-14)
|
|
2
18
|
|
|
3
19
|
|
|
@@ -14,16 +14,15 @@
|
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.uuvFoundedElement = exports.uuvFindByTestId = exports.uuvFindByText = exports.uuvFindByLabelText = exports.uuvFindByRole = exports.uuvFindAllByRole = exports.uuvPatchContext = exports.uuvCheckContextWithinFocusedElement = exports.uuvGetContext = exports.getA11yResultFilePath = exports.shouldGenerateA11yReport = void 0;
|
|
17
|
-
const ENV_GENERATE_A11_REPORT = "generateA11yReport";
|
|
18
17
|
const contextAlias = "context";
|
|
19
18
|
const foundedChildElementAlias = "foundedChildElement";
|
|
20
19
|
const shouldGenerateA11yReport = () => {
|
|
21
|
-
const generateA11yReport = Cypress.env(
|
|
20
|
+
const generateA11yReport = Cypress.env("uuvOptions").report.a11y.enabled;
|
|
22
21
|
return generateA11yReport === true;
|
|
23
22
|
};
|
|
24
23
|
exports.shouldGenerateA11yReport = shouldGenerateA11yReport;
|
|
25
24
|
const getA11yResultFilePath = () => {
|
|
26
|
-
return Cypress.env("
|
|
25
|
+
return Cypress.env("uuvOptions").report.a11y.outputFile;
|
|
27
26
|
};
|
|
28
27
|
exports.getA11yResultFilePath = getA11yResultFilePath;
|
|
29
28
|
const uuvGetContext = () => {
|
|
@@ -72,9 +72,9 @@ async function setupNodeEvents(on, config) {
|
|
|
72
72
|
on("before:run", async () => {
|
|
73
73
|
await (0, cypress_cucumber_preprocessor_1.beforeRunHandler)(config);
|
|
74
74
|
// eslint-disable-next-line dot-notation
|
|
75
|
-
const a11yReportFilePath = config.env["
|
|
75
|
+
const a11yReportFilePath = config.env["uuvOptions"].report.a11y.outputFile;
|
|
76
76
|
// eslint-disable-next-line dot-notation
|
|
77
|
-
const generateA11yReport = config.env["
|
|
77
|
+
const generateA11yReport = config.env["uuvOptions"].report.a11y.enabled;
|
|
78
78
|
clearA11yReport(a11yReportFilePath);
|
|
79
79
|
if (generateA11yReport === true) {
|
|
80
80
|
initA11yReport(a11yReportFilePath);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UUVCliOptions, UUVCliRunner } from "@uuv/runner-commons";
|
|
2
|
+
export declare class UUVCliCypressRunner implements UUVCliRunner {
|
|
3
|
+
projectDir: any;
|
|
4
|
+
name: string;
|
|
5
|
+
defaultBrowser: string;
|
|
6
|
+
private E2E_REPORT_DIR;
|
|
7
|
+
private JSON_REPORT_DIR;
|
|
8
|
+
private CYPRESS_JUNIT_REPORT;
|
|
9
|
+
private CUCUMBER_MESSAGES_FILE;
|
|
10
|
+
constructor(projectDir: any);
|
|
11
|
+
getCurrentVersion(): string;
|
|
12
|
+
prepare(options: Partial<UUVCliOptions>): void;
|
|
13
|
+
executeE2eCommand(options: Partial<UUVCliOptions>): Promise<void>;
|
|
14
|
+
executeOpenCommand(options: Partial<UUVCliOptions>): Promise<void>;
|
|
15
|
+
private createReportDirectories;
|
|
16
|
+
private terminateProcess;
|
|
17
|
+
private mergeJunitReport;
|
|
18
|
+
private generateHtmlReport;
|
|
19
|
+
private formatCucumberMessageFile;
|
|
20
|
+
private generateHtmlReportFromJson;
|
|
21
|
+
private getCypress;
|
|
22
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UUVCliCypressRunner = void 0;
|
|
7
|
+
const runner_commons_1 = require("@uuv/runner-commons");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const junit_report_merger_1 = require("junit-report-merger");
|
|
12
|
+
const uuv_custom_formatter_1 = require("../cucumber/uuv-custom-formatter");
|
|
13
|
+
const multiple_cucumber_html_reporter_1 = __importDefault(require("multiple-cucumber-html-reporter"));
|
|
14
|
+
const cypress_1 = __importDefault(require("cypress"));
|
|
15
|
+
class UUVCliCypressRunner {
|
|
16
|
+
projectDir;
|
|
17
|
+
name = "Cypress";
|
|
18
|
+
defaultBrowser = "chrome";
|
|
19
|
+
E2E_REPORT_DIR;
|
|
20
|
+
JSON_REPORT_DIR;
|
|
21
|
+
CYPRESS_JUNIT_REPORT;
|
|
22
|
+
CUCUMBER_MESSAGES_FILE;
|
|
23
|
+
constructor(projectDir) {
|
|
24
|
+
this.projectDir = projectDir;
|
|
25
|
+
}
|
|
26
|
+
getCurrentVersion() {
|
|
27
|
+
const pJsonStr = fs_1.default.readFileSync(`${__dirname}/../../package.json`, {
|
|
28
|
+
encoding: "utf8", flag: "r"
|
|
29
|
+
});
|
|
30
|
+
return JSON.parse(pJsonStr).version;
|
|
31
|
+
}
|
|
32
|
+
prepare(options) {
|
|
33
|
+
if (options.baseUrl) {
|
|
34
|
+
// eslint-disable-next-line dot-notation
|
|
35
|
+
process.env["CYPRESS_BASE_URL"] = options.baseUrl;
|
|
36
|
+
}
|
|
37
|
+
if (options.report) {
|
|
38
|
+
this.E2E_REPORT_DIR = path_1.default.join(options.report.outputDir, "e2e");
|
|
39
|
+
this.JSON_REPORT_DIR = path_1.default.join(this.E2E_REPORT_DIR, "json");
|
|
40
|
+
this.CYPRESS_JUNIT_REPORT = [`${this.projectDir}/reports/e2e/junit-report-*.xml`];
|
|
41
|
+
this.CUCUMBER_MESSAGES_FILE = path_1.default.join(this.projectDir, "cucumber-messages.ndjson");
|
|
42
|
+
this.createReportDirectories({ report: options.report });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
executeE2eCommand(options) {
|
|
46
|
+
const cypressOptions = {
|
|
47
|
+
project: this.projectDir,
|
|
48
|
+
browser: options.browser,
|
|
49
|
+
env: {
|
|
50
|
+
uuvOptions: options,
|
|
51
|
+
...options.extraArgs
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
if (options.report?.junit.enabled) {
|
|
55
|
+
cypressOptions.reporter = "junit";
|
|
56
|
+
cypressOptions.reporterOptions = {
|
|
57
|
+
mochaFile: "reports/e2e/junit-report-[hash].xml"
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (options.targetTestFile) {
|
|
61
|
+
cypressOptions.spec = options.targetTestFile;
|
|
62
|
+
}
|
|
63
|
+
// Running Tests
|
|
64
|
+
return this.getCypress()
|
|
65
|
+
.run(cypressOptions)
|
|
66
|
+
.then(async (result) => {
|
|
67
|
+
if (options.report?.junit.enabled) {
|
|
68
|
+
await this.mergeJunitReport(this.CYPRESS_JUNIT_REPORT, options.report.junit.outputFile);
|
|
69
|
+
}
|
|
70
|
+
if (options.report?.html.enabled) {
|
|
71
|
+
await this.generateHtmlReport(options, options.report.html.outputDir);
|
|
72
|
+
}
|
|
73
|
+
if (fs_1.default.existsSync(this.CUCUMBER_MESSAGES_FILE)) {
|
|
74
|
+
fs_1.default.rmSync(this.CUCUMBER_MESSAGES_FILE);
|
|
75
|
+
}
|
|
76
|
+
if ("totalFailed" in result) {
|
|
77
|
+
console.log(`Status ${result.totalFailed ? chalk_1.default.red("failed") : chalk_1.default.green("success")}`);
|
|
78
|
+
this.terminateProcess(result.totalFailed === 0 ? 0 : 2);
|
|
79
|
+
}
|
|
80
|
+
this.terminateProcess(0);
|
|
81
|
+
})
|
|
82
|
+
.catch(async (err) => {
|
|
83
|
+
console.error(chalk_1.default.red(err));
|
|
84
|
+
if (options.report?.junit.enabled) {
|
|
85
|
+
await this.mergeJunitReport(this.CYPRESS_JUNIT_REPORT, options.report.junit.outputFile);
|
|
86
|
+
}
|
|
87
|
+
this.terminateProcess(2);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
executeOpenCommand(options) {
|
|
91
|
+
return this.getCypress().open({
|
|
92
|
+
project: this.projectDir,
|
|
93
|
+
env: options.extraArgs,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
createReportDirectories(options) {
|
|
97
|
+
if (!fs_1.default.existsSync(options.report.outputDir)) {
|
|
98
|
+
fs_1.default.mkdirSync(options.report.outputDir);
|
|
99
|
+
}
|
|
100
|
+
if (fs_1.default.existsSync(this.E2E_REPORT_DIR)) {
|
|
101
|
+
runner_commons_1.Common.deleteAllFileOfDirectory(this.E2E_REPORT_DIR);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
fs_1.default.mkdirSync(this.E2E_REPORT_DIR, { recursive: true });
|
|
105
|
+
}
|
|
106
|
+
if (!fs_1.default.existsSync(this.JSON_REPORT_DIR)) {
|
|
107
|
+
fs_1.default.mkdirSync(this.JSON_REPORT_DIR, { recursive: true });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
terminateProcess(exitCode) {
|
|
111
|
+
process.exit(exitCode);
|
|
112
|
+
}
|
|
113
|
+
async mergeJunitReport(inputFiles, outputFile) {
|
|
114
|
+
console.info(chalk_1.default.blueBright("Generating Junit Test Report..."));
|
|
115
|
+
await (0, junit_report_merger_1.mergeFiles)(outputFile, inputFiles);
|
|
116
|
+
console.info(chalk_1.default.blueBright(`Junit Test Report generated: ${outputFile}\n`));
|
|
117
|
+
}
|
|
118
|
+
async generateHtmlReport(options, reportDir) {
|
|
119
|
+
console.info(chalk_1.default.blueBright("Generating Html Test Report..."));
|
|
120
|
+
await this.formatCucumberMessageFile(this.JSON_REPORT_DIR, this.CUCUMBER_MESSAGES_FILE);
|
|
121
|
+
this.generateHtmlReportFromJson(options, this.JSON_REPORT_DIR, reportDir);
|
|
122
|
+
}
|
|
123
|
+
async formatCucumberMessageFile(jsonReportDir, cucumberMessageFile) {
|
|
124
|
+
const formatter = new uuv_custom_formatter_1.UuvCustomFormatter();
|
|
125
|
+
const outputFile = `${jsonReportDir}/cucumber-report.json`;
|
|
126
|
+
await formatter.parseCucumberJson(cucumberMessageFile, outputFile);
|
|
127
|
+
}
|
|
128
|
+
generateHtmlReportFromJson(options, jsonReportDir, htmlReportDir) {
|
|
129
|
+
const UNKNOWN_VALUE = "unknown";
|
|
130
|
+
multiple_cucumber_html_reporter_1.default.generate({
|
|
131
|
+
jsonDir: jsonReportDir,
|
|
132
|
+
reportPath: htmlReportDir,
|
|
133
|
+
metadata: {
|
|
134
|
+
browser: {
|
|
135
|
+
name: options.browser,
|
|
136
|
+
version: options.extraArgs?.browserVersion ? options.extraArgs.browserVersion : "",
|
|
137
|
+
},
|
|
138
|
+
device: options.extraArgs?.device ? options.extraArgs.device : UNKNOWN_VALUE,
|
|
139
|
+
platform: {
|
|
140
|
+
name: options.extraArgs?.platformName ? options.extraArgs.platformName : UNKNOWN_VALUE,
|
|
141
|
+
version: options.extraArgs?.platformVersion ? options.extraArgs.platformVersion : "",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
getCypress() {
|
|
147
|
+
return cypress_1.default;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.UUVCliCypressRunner = UUVCliCypressRunner;
|
package/dist/lib/uuv-cli.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.main = void 0;
|
|
5
|
+
const runner_commons_1 = require("@uuv/runner-commons");
|
|
6
|
+
const runner_cypress_1 = require("./runner-cypress");
|
|
3
7
|
/**
|
|
4
8
|
* Software Name : UUV
|
|
5
9
|
*
|
|
@@ -13,206 +17,8 @@
|
|
|
13
17
|
* Software description: Make test writing fast, understandable by any human
|
|
14
18
|
* understanding English or French.
|
|
15
19
|
*/
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.main = void 0;
|
|
21
|
-
const multiple_cucumber_html_reporter_1 = __importDefault(require("multiple-cucumber-html-reporter"));
|
|
22
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
23
|
-
const figlet_1 = __importDefault(require("figlet"));
|
|
24
|
-
const minimist_1 = __importDefault(require("minimist"));
|
|
25
|
-
const fs_1 = __importDefault(require("fs"));
|
|
26
|
-
const cypress_1 = __importDefault(require("cypress"));
|
|
27
|
-
const uuv_custom_formatter_1 = require("../cucumber/uuv-custom-formatter");
|
|
28
|
-
const path_1 = __importDefault(require("path"));
|
|
29
20
|
async function main(projectDir = "./uuv") {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const JSON_REPORT_DIR = path_1.default.join(projectDir, "reports/e2e/json");
|
|
33
|
-
const HTML_REPORT_DIR = path_1.default.join(projectDir, "reports/e2e/html");
|
|
34
|
-
const CYPRESS_JUNIT_REPORT = [`${projectDir}/reports/e2e/junit-report-*.xml`];
|
|
35
|
-
const JUNIT_UNIFIED_REPORT = `${projectDir}/reports/e2e/junit-report.xml`;
|
|
36
|
-
const CUCUMBER_MESSAGES_FILE = path_1.default.join(projectDir, "cucumber-messages.ndjson");
|
|
37
|
-
printBanner(getCurrentVersion);
|
|
38
|
-
setBaseUrl();
|
|
39
|
-
const argv = (0, minimist_1.default)(process.argv.slice(2));
|
|
40
|
-
const command = findTargetCommand(argv);
|
|
41
|
-
console.info(chalk_1.default.blueBright(`Executing UUV command ${command}...`));
|
|
42
|
-
createReportDirectories();
|
|
43
|
-
await executeCommand();
|
|
44
|
-
console.info(`UUV command ${command} executed`);
|
|
45
|
-
function setBaseUrl() {
|
|
46
|
-
// eslint-disable-next-line dot-notation
|
|
47
|
-
const baseUrl = process.env["UUV_BASE_URL"];
|
|
48
|
-
if (baseUrl) {
|
|
49
|
-
// eslint-disable-next-line dot-notation
|
|
50
|
-
process.env["CYPRESS_BASE_URL"] = process.env["UUV_BASE_URL"];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function createReportDirectories() {
|
|
54
|
-
if (!fs_1.default.existsSync(REPORT_DIR)) {
|
|
55
|
-
fs_1.default.mkdirSync(REPORT_DIR);
|
|
56
|
-
}
|
|
57
|
-
if (fs_1.default.existsSync(E2E_REPORT_DIR)) {
|
|
58
|
-
deleteAllFileOfDirectory(E2E_REPORT_DIR);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function executeCommand() {
|
|
62
|
-
switch (command) {
|
|
63
|
-
case "open":
|
|
64
|
-
await openCypress(argv);
|
|
65
|
-
break;
|
|
66
|
-
case "e2e":
|
|
67
|
-
await runE2ETests(argv);
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
console.error(chalk_1.default.red("Unknown command"));
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function extractArgs(argv) {
|
|
75
|
-
const browser = argv.browser ? argv.browser : "chrome";
|
|
76
|
-
const env = argv.env ? JSON.parse(argv.env.replace(/'/g, "\"")) : {};
|
|
77
|
-
const targetTestFile = argv.targetTestFile ? argv.targetTestFile : null;
|
|
78
|
-
if (argv.generateA11yReport) {
|
|
79
|
-
env.uuvA11yReportFilePath = `${process.cwd()}/${REPORT_DIR}/a11y-report.json`;
|
|
80
|
-
env.generateA11yReport = argv.generateA11yReport;
|
|
81
|
-
}
|
|
82
|
-
env.generateJunitReport = argv.generateJunitReport;
|
|
83
|
-
env.generateHtmlReport = argv.generateHtmlReport;
|
|
84
|
-
console.debug("Variables: ");
|
|
85
|
-
// eslint-disable-next-line dot-notation
|
|
86
|
-
const baseUrl = process.env["CYPRESS_BASE_URL"];
|
|
87
|
-
if (baseUrl) {
|
|
88
|
-
console.debug(` -> baseUrl: ${baseUrl}`);
|
|
89
|
-
}
|
|
90
|
-
console.debug(` -> browser: ${browser}`);
|
|
91
|
-
console.debug(` -> env: ${JSON.stringify(env)}`);
|
|
92
|
-
if (targetTestFile) {
|
|
93
|
-
console.debug(` -> targetTestFile: ${targetTestFile}`);
|
|
94
|
-
}
|
|
95
|
-
return { browser, env, targetTestFile };
|
|
96
|
-
}
|
|
97
|
-
function openCypress(argv) {
|
|
98
|
-
const { env } = extractArgs(argv);
|
|
99
|
-
return cypress_1.default.open({
|
|
100
|
-
project: projectDir,
|
|
101
|
-
env,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
function runE2ETests(argv) {
|
|
105
|
-
const { browser, env, targetTestFile } = extractArgs(argv);
|
|
106
|
-
const options = {
|
|
107
|
-
project: projectDir,
|
|
108
|
-
browser,
|
|
109
|
-
env
|
|
110
|
-
};
|
|
111
|
-
if (env.generateJunitReport) {
|
|
112
|
-
options.reporter = "junit";
|
|
113
|
-
options.reporterOptions = {
|
|
114
|
-
mochaFile: "reports/e2e/junit-report-[hash].xml"
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
if (targetTestFile) {
|
|
118
|
-
options.spec = targetTestFile;
|
|
119
|
-
}
|
|
120
|
-
// Running Tests
|
|
121
|
-
return cypress_1.default
|
|
122
|
-
.run(options)
|
|
123
|
-
.then(async (result) => {
|
|
124
|
-
if (env.generateJunitReport) {
|
|
125
|
-
await mergeJunitReport(CYPRESS_JUNIT_REPORT, JUNIT_UNIFIED_REPORT);
|
|
126
|
-
}
|
|
127
|
-
if (env.generateHtmlReport) {
|
|
128
|
-
console.info(chalk_1.default.blueBright("Generating Html Test Report..."));
|
|
129
|
-
await generateHtmlReport(browser, argv);
|
|
130
|
-
}
|
|
131
|
-
if (fs_1.default.existsSync(CUCUMBER_MESSAGES_FILE)) {
|
|
132
|
-
fs_1.default.rmSync(CUCUMBER_MESSAGES_FILE);
|
|
133
|
-
}
|
|
134
|
-
if ("totalFailed" in result) {
|
|
135
|
-
console.log(`Status ${result.totalFailed ? chalk_1.default.red("failed") : chalk_1.default.green("success")}`);
|
|
136
|
-
process.exit(result.totalFailed);
|
|
137
|
-
}
|
|
138
|
-
process.exit();
|
|
139
|
-
})
|
|
140
|
-
.catch(async (err) => {
|
|
141
|
-
console.error(chalk_1.default.red(err));
|
|
142
|
-
if (env.generateJunitReport) {
|
|
143
|
-
await mergeJunitReport(CYPRESS_JUNIT_REPORT, JUNIT_UNIFIED_REPORT);
|
|
144
|
-
}
|
|
145
|
-
process.exit(-1);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
async function formatCucumberMessageFile() {
|
|
149
|
-
// Creating needed dirs
|
|
150
|
-
if (!fs_1.default.existsSync(JSON_REPORT_DIR)) {
|
|
151
|
-
fs_1.default.mkdirSync(JSON_REPORT_DIR, { recursive: true });
|
|
152
|
-
}
|
|
153
|
-
const formatter = new uuv_custom_formatter_1.UuvCustomFormatter();
|
|
154
|
-
const outputFile = `${JSON_REPORT_DIR}/cucumber-report.json`;
|
|
155
|
-
await formatter.parseCucumberJson(CUCUMBER_MESSAGES_FILE, outputFile);
|
|
156
|
-
}
|
|
157
|
-
function generateHtmlReportFromJson(browser, argv) {
|
|
158
|
-
const UNKNOWN_VALUE = "unknown";
|
|
159
|
-
multiple_cucumber_html_reporter_1.default.generate({
|
|
160
|
-
jsonDir: JSON_REPORT_DIR,
|
|
161
|
-
reportPath: HTML_REPORT_DIR,
|
|
162
|
-
metadata: {
|
|
163
|
-
browser: {
|
|
164
|
-
name: browser,
|
|
165
|
-
version: argv.browserVersion ? argv.browserVersion : "",
|
|
166
|
-
},
|
|
167
|
-
device: argv.device ? argv.device : UNKNOWN_VALUE,
|
|
168
|
-
platform: {
|
|
169
|
-
name: argv.platformName ? argv.platformName : UNKNOWN_VALUE,
|
|
170
|
-
version: argv.platformVersion ? argv.platformVersion : "",
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
async function generateHtmlReport(browser, argv) {
|
|
176
|
-
await formatCucumberMessageFile();
|
|
177
|
-
generateHtmlReportFromJson(browser, argv);
|
|
178
|
-
}
|
|
179
|
-
function findTargetCommand(argv) {
|
|
180
|
-
if (argv._.length < 1) {
|
|
181
|
-
console.error(chalk_1.default.red("No command specified"));
|
|
182
|
-
process.exit(1);
|
|
183
|
-
}
|
|
184
|
-
const command = argv._[0];
|
|
185
|
-
return command;
|
|
186
|
-
}
|
|
187
|
-
function printBanner(getCurrentVersion) {
|
|
188
|
-
console.log(chalk_1.default.blueBright(figlet_1.default.textSync("UUV - Cypress", {
|
|
189
|
-
font: "Big",
|
|
190
|
-
horizontalLayout: "default",
|
|
191
|
-
verticalLayout: "default",
|
|
192
|
-
width: 80,
|
|
193
|
-
whitespaceBreak: true
|
|
194
|
-
})));
|
|
195
|
-
console.info(chalk_1.default.blueBright(`Version: ${getCurrentVersion()}\n\n`));
|
|
196
|
-
}
|
|
197
|
-
function getCurrentVersion() {
|
|
198
|
-
const pJsonStr = fs_1.default.readFileSync(`${__dirname}/../../package.json`, {
|
|
199
|
-
encoding: "utf8", flag: "r"
|
|
200
|
-
});
|
|
201
|
-
return JSON.parse(pJsonStr).version;
|
|
202
|
-
}
|
|
203
|
-
async function mergeJunitReport(inputFiles, outputFile) {
|
|
204
|
-
const { mergeFiles } = require("junit-report-merger");
|
|
205
|
-
console.info(chalk_1.default.blueBright("Generating Junit Test Report..."));
|
|
206
|
-
await mergeFiles(outputFile, inputFiles);
|
|
207
|
-
console.info(chalk_1.default.blueBright(`Junit Test Report generated: ${outputFile}`));
|
|
208
|
-
}
|
|
209
|
-
function deleteAllFileOfDirectory(dirPath) {
|
|
210
|
-
for (const file of fs_1.default.readdirSync(dirPath)) {
|
|
211
|
-
const filePath = path_1.default.join(dirPath, file);
|
|
212
|
-
if (fs_1.default.lstatSync(filePath).isFile()) {
|
|
213
|
-
fs_1.default.rmSync(filePath);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
21
|
+
const engine = new runner_commons_1.UUVCliEngine(new runner_cypress_1.UUVCliCypressRunner(projectDir));
|
|
22
|
+
engine.execute();
|
|
217
23
|
}
|
|
218
24
|
exports.main = main;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uuv/cypress",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.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 facilitate the writing and execution of E2E tests understandable by any human being using cucumber(BDD) and cypress",
|
|
@@ -36,32 +36,30 @@
|
|
|
36
36
|
"generate:step-definitions": "ts-node generate-step-definitions.ts",
|
|
37
37
|
"package": "npm pack --pack-destination=\"../../dist/packages\"",
|
|
38
38
|
"postinstall": "node postinstall.js",
|
|
39
|
-
"test
|
|
40
|
-
"test:
|
|
41
|
-
"test": "
|
|
39
|
+
"unit-test": "jest --runInBand --coverage --config=./jest.config.ts",
|
|
40
|
+
"e2e-test:run": "node test.js e2e",
|
|
41
|
+
"e2e-test:open": "node test.js open --",
|
|
42
|
+
"test": "npm run unit-test && npm run e2e-test:run",
|
|
42
43
|
"lint": "eslint -c .eslintrc.json"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@badeball/cypress-cucumber-preprocessor": "16.0.3",
|
|
46
47
|
"@cypress/webpack-preprocessor": "6.0.1",
|
|
47
48
|
"@testing-library/cypress": "10.0.1",
|
|
48
|
-
"@uuv/a11y": "1.0.0-beta.
|
|
49
|
-
"@uuv/runner-commons": "2.
|
|
49
|
+
"@uuv/a11y": "1.0.0-beta.24",
|
|
50
|
+
"@uuv/runner-commons": "2.12.0",
|
|
50
51
|
"axe-core": "4.9.0",
|
|
51
52
|
"chai-subset": "^1.6.0",
|
|
52
|
-
"chalk": "4.1.2",
|
|
53
53
|
"cucumber-json-report-formatter": "0.1.4",
|
|
54
54
|
"cypress": "12.17.4",
|
|
55
55
|
"cypress-axe": "1.5.0",
|
|
56
56
|
"cypress-real-events": "^1.10.0",
|
|
57
|
-
"figlet": "1.7.0",
|
|
58
57
|
"is-admin": "4.0.0",
|
|
59
58
|
"junit-report-merger": "^6.0.3",
|
|
60
|
-
"minimist": "1.2.8",
|
|
61
59
|
"multiple-cucumber-html-reporter": "3.6.2",
|
|
62
60
|
"path-browserify": "^1.0.1",
|
|
63
61
|
"ts-node": "10.9.2",
|
|
64
|
-
"typescript": "4.
|
|
62
|
+
"typescript": "5.4.5",
|
|
65
63
|
"webpack": "5.90.3"
|
|
66
64
|
},
|
|
67
65
|
"types": "./dist/index.d.ts",
|
|
@@ -102,9 +100,10 @@
|
|
|
102
100
|
},
|
|
103
101
|
"devDependencies": {
|
|
104
102
|
"@types/minimist": "1.2.5",
|
|
105
|
-
"@types/node": "20.
|
|
103
|
+
"@types/node": "20.12.7",
|
|
104
|
+
"chalk": "^4.1.2",
|
|
106
105
|
"cross-env": "7.0.3",
|
|
107
|
-
"eslint-plugin-cypress": "2.15.
|
|
106
|
+
"eslint-plugin-cypress": "2.15.2",
|
|
108
107
|
"ts-loader": "9.4.2",
|
|
109
108
|
"tsconfig-paths": "4.2.0"
|
|
110
109
|
}
|