@uuv/runner-commons 2.10.1 → 2.12.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 +15 -0
- package/dist/cli/engine.d.ts +7 -0
- package/dist/cli/engine.js +44 -0
- package/dist/cli/helper.d.ts +12 -0
- package/dist/cli/helper.js +91 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.js +20 -0
- package/dist/cli/options.d.ts +22 -0
- package/dist/cli/options.js +2 -0
- package/dist/cli/runner.d.ts +34 -0
- package/dist/cli/runner.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/step-definition-generator/common.d.ts +2 -0
- package/dist/step-definition-generator/common.js +11 -3
- package/dist/step-definition-generator/lang-enum.js +1 -1
- package/package.json +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [2.12.0](https://github.com/Orange-OpenSource/uuv/compare/runner-commons-v2.11.0...runner-commons-v2.12.0) (2024-05-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update package-lock for update dependency typescript to v5 ([f058481](https://github.com/Orange-OpenSource/uuv/commit/f058481e2ae75ba91e708a5c4dd8ce16c0f1a04f))
|
|
7
|
+
|
|
8
|
+
# [2.11.0](https://github.com/Orange-OpenSource/uuv/compare/runner-commons-v2.10.1...runner-commons-v2.11.0) (2024-04-22)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* (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))
|
|
14
|
+
* 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))
|
|
15
|
+
|
|
1
16
|
## [2.10.1](https://github.com/Orange-OpenSource/uuv/compare/runner-commons-v2.10.0...runner-commons-v2.10.1) (2024-04-14)
|
|
2
17
|
|
|
3
18
|
|
|
@@ -0,0 +1,44 @@
|
|
|
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.UUVCliEngine = void 0;
|
|
7
|
+
const helper_1 = require("./helper");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
class UUVCliEngine {
|
|
10
|
+
runner;
|
|
11
|
+
constructor(runner) {
|
|
12
|
+
this.runner = runner;
|
|
13
|
+
}
|
|
14
|
+
async execute() {
|
|
15
|
+
try {
|
|
16
|
+
helper_1.UUVCliHelper.printBanner(this.runner.name, this.runner.getCurrentVersion());
|
|
17
|
+
this.checkArguments();
|
|
18
|
+
const options = helper_1.UUVCliHelper.extractArgs(this.runner.projectDir, this.runner.defaultBrowser);
|
|
19
|
+
helper_1.UUVCliHelper.printVariables(options);
|
|
20
|
+
await this.runner.prepare(options);
|
|
21
|
+
console.info(chalk_1.default.blueBright(`Executing UUV command ${options.command}...`));
|
|
22
|
+
switch (options.command) {
|
|
23
|
+
case "open":
|
|
24
|
+
await this.runner.executeOpenCommand(options);
|
|
25
|
+
break;
|
|
26
|
+
case "e2e":
|
|
27
|
+
await this.runner.executeE2eCommand(options);
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
throw new Error("Unknown command");
|
|
31
|
+
}
|
|
32
|
+
console.info(`UUV command ${options.command} executed`);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.error(chalk_1.default.red(e));
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
checkArguments() {
|
|
40
|
+
helper_1.UUVCliHelper.checkTargetCommand();
|
|
41
|
+
helper_1.UUVCliHelper.checkTargetTestFiles();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.UUVCliEngine = UUVCliEngine;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UUVCliOptions } from "./options";
|
|
2
|
+
export declare class UUVCliHelper {
|
|
3
|
+
/**
|
|
4
|
+
* Print runner banner
|
|
5
|
+
*/
|
|
6
|
+
static printBanner(runnerName: string, currentVersion: string): void;
|
|
7
|
+
static checkTargetCommand(): void;
|
|
8
|
+
static checkTargetTestFiles(): void;
|
|
9
|
+
private static getTargetCommand;
|
|
10
|
+
static extractArgs(projectDir: string, defaultBrowser: any): Partial<UUVCliOptions>;
|
|
11
|
+
static printVariables(options: Partial<UUVCliOptions>): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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.UUVCliHelper = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const figlet_1 = __importDefault(require("figlet"));
|
|
9
|
+
const minimist_1 = __importDefault(require("minimist"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const lodash_1 = require("lodash");
|
|
12
|
+
class UUVCliHelper {
|
|
13
|
+
/**
|
|
14
|
+
* Print runner banner
|
|
15
|
+
*/
|
|
16
|
+
static printBanner(runnerName, currentVersion) {
|
|
17
|
+
console.log(chalk_1.default.blueBright(figlet_1.default.textSync(`UUV - ${runnerName}`, {
|
|
18
|
+
font: "Big",
|
|
19
|
+
horizontalLayout: "default",
|
|
20
|
+
verticalLayout: "default",
|
|
21
|
+
width: 80,
|
|
22
|
+
whitespaceBreak: true
|
|
23
|
+
})));
|
|
24
|
+
console.info(chalk_1.default.blueBright(`Version: ${currentVersion}\n\n`));
|
|
25
|
+
}
|
|
26
|
+
static checkTargetCommand() {
|
|
27
|
+
const argv = (0, minimist_1.default)(process.argv.slice(2));
|
|
28
|
+
if (argv._.length < 1) {
|
|
29
|
+
throw new Error("No command specified");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
static checkTargetTestFiles() {
|
|
33
|
+
const argv = (0, minimist_1.default)(process.argv.slice(2));
|
|
34
|
+
const targetTestFile = argv.targetTestFile;
|
|
35
|
+
if (!(0, lodash_1.isEmpty)(targetTestFile)) {
|
|
36
|
+
try {
|
|
37
|
+
new RegExp(targetTestFile, "gi");
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
throw new Error("Invalid targetTestFile argument, this args should respect Glob pattern");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
static getTargetCommand(argv) {
|
|
45
|
+
return argv._[0];
|
|
46
|
+
}
|
|
47
|
+
static extractArgs(projectDir, defaultBrowser) {
|
|
48
|
+
const argv = (0, minimist_1.default)(process.argv.slice(2));
|
|
49
|
+
const browser = argv.browser ? argv.browser : defaultBrowser;
|
|
50
|
+
const env = argv.env ? JSON.parse(argv.env.replace(/'/g, "\"")) : {};
|
|
51
|
+
const targetTestFile = argv.targetTestFile ? argv.targetTestFile : null;
|
|
52
|
+
const reportDir = path_1.default.join(projectDir, "reports");
|
|
53
|
+
return {
|
|
54
|
+
// eslint-disable-next-line dot-notation
|
|
55
|
+
baseUrl: process.env["UUV_BASE_URL"],
|
|
56
|
+
browser,
|
|
57
|
+
extraArgs: env,
|
|
58
|
+
targetTestFile,
|
|
59
|
+
command: this.getTargetCommand(argv),
|
|
60
|
+
report: {
|
|
61
|
+
outputDir: reportDir,
|
|
62
|
+
a11y: {
|
|
63
|
+
enabled: argv.generateA11yReport,
|
|
64
|
+
outputFile: path_1.default.join(process.cwd(), reportDir, "a11y-report.json")
|
|
65
|
+
},
|
|
66
|
+
html: {
|
|
67
|
+
enabled: argv.generateHtmlReport,
|
|
68
|
+
outputDir: path_1.default.join(reportDir, "e2e/html")
|
|
69
|
+
},
|
|
70
|
+
junit: {
|
|
71
|
+
enabled: argv.generateJunitReport,
|
|
72
|
+
outputFile: path_1.default.join(reportDir, "e2e/junit-report.xml")
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static printVariables(options) {
|
|
78
|
+
console.debug(chalk_1.default.yellowBright("Variables: "));
|
|
79
|
+
if (options.baseUrl) {
|
|
80
|
+
console.debug(` -> baseUrl: ${options.baseUrl}`);
|
|
81
|
+
}
|
|
82
|
+
console.debug(` -> browser: ${options.browser}`);
|
|
83
|
+
console.debug(` -> report: ${JSON.stringify(options.report)}`);
|
|
84
|
+
console.debug(` -> env: ${JSON.stringify(options.extraArgs)}`);
|
|
85
|
+
if (options.targetTestFile) {
|
|
86
|
+
console.debug(` -> targetTestFile: ${options.targetTestFile}`);
|
|
87
|
+
}
|
|
88
|
+
console.debug("\n");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.UUVCliHelper = UUVCliHelper;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./engine"), exports);
|
|
18
|
+
__exportStar(require("./helper"), exports);
|
|
19
|
+
__exportStar(require("./options"), exports);
|
|
20
|
+
__exportStar(require("./runner"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type UUVCliOptions = {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
command: "open" | "e2e";
|
|
4
|
+
browser: string;
|
|
5
|
+
targetTestFile: string;
|
|
6
|
+
report: {
|
|
7
|
+
outputDir: string;
|
|
8
|
+
a11y: {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
outputFile: string;
|
|
11
|
+
};
|
|
12
|
+
html: {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
outputDir: string;
|
|
15
|
+
};
|
|
16
|
+
junit: {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
outputFile: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
extraArgs: any;
|
|
22
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { UUVCliOptions } from "./options";
|
|
2
|
+
export interface UUVCliRunner {
|
|
3
|
+
/**
|
|
4
|
+
* Runner name e.g: Cypress, Playwright
|
|
5
|
+
*/
|
|
6
|
+
name: string;
|
|
7
|
+
/**
|
|
8
|
+
* Project directory
|
|
9
|
+
*/
|
|
10
|
+
projectDir: string;
|
|
11
|
+
/**
|
|
12
|
+
* Default browser
|
|
13
|
+
*/
|
|
14
|
+
defaultBrowser: string;
|
|
15
|
+
/**
|
|
16
|
+
* Return runner current version
|
|
17
|
+
*/
|
|
18
|
+
getCurrentVersion(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Prepare runner to execute command
|
|
21
|
+
* @param options
|
|
22
|
+
*/
|
|
23
|
+
prepare(options: Partial<UUVCliOptions>): any;
|
|
24
|
+
/**
|
|
25
|
+
* Execute "e2e" command
|
|
26
|
+
* @param options
|
|
27
|
+
*/
|
|
28
|
+
executeE2eCommand(options: Partial<UUVCliOptions>): any;
|
|
29
|
+
/**
|
|
30
|
+
* Execute "open" command
|
|
31
|
+
* @param options
|
|
32
|
+
*/
|
|
33
|
+
executeOpenCommand(options: Partial<UUVCliOptions>): any;
|
|
34
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,3 +28,4 @@ exports.key = template_json_1.default;
|
|
|
28
28
|
var accessible_role_1 = require("./step-definition-generator/accessible-role");
|
|
29
29
|
Object.defineProperty(exports, "AccessibleRole", { enumerable: true, get: function () { return accessible_role_1.AccessibleRole; } });
|
|
30
30
|
__exportStar(require("./assets/i18n/web/en"), exports);
|
|
31
|
+
__exportStar(require("./cli"), exports);
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* Software description: Make test writing fast, understandable by any human
|
|
12
12
|
* understanding English or French.
|
|
13
13
|
*/
|
|
14
|
+
/// <reference types="node" />
|
|
14
15
|
import fs from "fs";
|
|
15
16
|
import { AccessibleRole } from "./accessible-role";
|
|
16
17
|
export { fs };
|
|
@@ -46,4 +47,5 @@ export declare class Common {
|
|
|
46
47
|
static cleanGeneratedFilesIfExists(generatedFile: string): void;
|
|
47
48
|
static cleanFolderIfExists(folder: string): void;
|
|
48
49
|
static writeWordingFile(generatedFile: string, data: string): void;
|
|
50
|
+
static deleteAllFileOfDirectory(dirPath: any): void;
|
|
49
51
|
}
|
|
@@ -74,12 +74,12 @@ var TEST_RUNNER_ENUM;
|
|
|
74
74
|
(function (TEST_RUNNER_ENUM) {
|
|
75
75
|
TEST_RUNNER_ENUM["CYPRESS"] = "cypress";
|
|
76
76
|
TEST_RUNNER_ENUM["PLAYWRIGHT"] = "playwright";
|
|
77
|
-
})(TEST_RUNNER_ENUM
|
|
77
|
+
})(TEST_RUNNER_ENUM || (exports.TEST_RUNNER_ENUM = TEST_RUNNER_ENUM = {}));
|
|
78
78
|
var STEP_DEFINITION_FILE_NAME;
|
|
79
79
|
(function (STEP_DEFINITION_FILE_NAME) {
|
|
80
80
|
STEP_DEFINITION_FILE_NAME["BASE"] = "base-check-engine";
|
|
81
81
|
STEP_DEFINITION_FILE_NAME["BY_ROLE"] = "based-role-check-engine";
|
|
82
|
-
})(STEP_DEFINITION_FILE_NAME
|
|
82
|
+
})(STEP_DEFINITION_FILE_NAME || (exports.STEP_DEFINITION_FILE_NAME = STEP_DEFINITION_FILE_NAME = {}));
|
|
83
83
|
var KEY_PRESS;
|
|
84
84
|
(function (KEY_PRESS) {
|
|
85
85
|
KEY_PRESS["TAB"] = "{tab}";
|
|
@@ -88,7 +88,7 @@ var KEY_PRESS;
|
|
|
88
88
|
KEY_PRESS["DOWN"] = "{down}";
|
|
89
89
|
KEY_PRESS["LEFT"] = "{left}";
|
|
90
90
|
KEY_PRESS["RIGHT"] = "{right}";
|
|
91
|
-
})(KEY_PRESS
|
|
91
|
+
})(KEY_PRESS || (exports.KEY_PRESS = KEY_PRESS = {}));
|
|
92
92
|
class Common {
|
|
93
93
|
static buildDirIfNotExists(directory) {
|
|
94
94
|
console.log(`[CREATE] ${directory} CREATE successfully`);
|
|
@@ -114,5 +114,13 @@ class Common {
|
|
|
114
114
|
fs_1.default.writeFileSync(generatedFile, data);
|
|
115
115
|
console.log(`[WRITE] ${generatedFile} written successfully`);
|
|
116
116
|
}
|
|
117
|
+
static deleteAllFileOfDirectory(dirPath) {
|
|
118
|
+
for (const file of fs_1.default.readdirSync(dirPath)) {
|
|
119
|
+
const filePath = path.join(dirPath, file);
|
|
120
|
+
if (fs_1.default.lstatSync(filePath).isFile()) {
|
|
121
|
+
fs_1.default.rmSync(filePath);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
117
125
|
}
|
|
118
126
|
exports.Common = Common;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uuv/runner-commons",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.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 common lib for uuv",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"package": "npm pack --pack-destination=\"../../dist/packages\"",
|
|
34
34
|
"lint": "npx eslint . --ext .js,.ts,.feature --fix",
|
|
35
|
-
"test": "
|
|
35
|
+
"test": "npm run unit-test --",
|
|
36
|
+
"unit-test": "jest --coverage"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@typescript-eslint/eslint-plugin": "5.62.0",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"dist/assets/**/*",
|
|
48
49
|
"src/assets/i18n/*/*/*.json",
|
|
49
50
|
"dist/runner/**/*",
|
|
51
|
+
"dist/cli/**/*",
|
|
50
52
|
"*.md"
|
|
51
53
|
],
|
|
52
54
|
"exports": {
|
|
@@ -65,5 +67,11 @@
|
|
|
65
67
|
"require": "./dist/assets/i18n/web/en/index.js",
|
|
66
68
|
"types": "./dist/assets/i18n/web/en/index.d.ts"
|
|
67
69
|
}
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"chalk": "^4.1.2",
|
|
73
|
+
"figlet": "1.7.0",
|
|
74
|
+
"lodash": "^4.17.21",
|
|
75
|
+
"minimist": "1.2.8"
|
|
68
76
|
}
|
|
69
77
|
}
|