artes 1.2.17 → 1.2.18
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/README.md +629 -629
- package/cucumber.config.js +171 -171
- package/docs/functionDefinitions.md +2401 -2401
- package/docs/stepDefinitions.md +391 -391
- package/executer.js +161 -161
- package/index.js +48 -48
- package/package.json +52 -51
- package/src/helper/contextManager/browserManager.js +63 -63
- package/src/helper/contextManager/requestManager.js +23 -23
- package/src/helper/controller/elementController.js +182 -182
- package/src/helper/controller/pomCollector.js +25 -25
- package/src/helper/executers/cleaner.js +19 -19
- package/src/helper/executers/exporter.js +15 -15
- package/src/helper/executers/helper.js +95 -95
- package/src/helper/executers/projectCreator.js +198 -198
- package/src/helper/executers/reportGenerator.js +58 -58
- package/src/helper/executers/testRunner.js +30 -30
- package/src/helper/executers/versionChecker.js +31 -31
- package/src/helper/imports/commons.js +56 -56
- package/src/helper/stepFunctions/APIActions.js +362 -362
- package/src/helper/stepFunctions/assertions.js +523 -523
- package/src/helper/stepFunctions/browserActions.js +22 -22
- package/src/helper/stepFunctions/elementInteractions.js +38 -38
- package/src/helper/stepFunctions/exporter.js +19 -19
- package/src/helper/stepFunctions/frameActions.js +50 -50
- package/src/helper/stepFunctions/keyboardActions.js +41 -41
- package/src/helper/stepFunctions/mouseActions.js +145 -145
- package/src/helper/stepFunctions/pageActions.js +27 -27
- package/src/hooks/context.js +15 -15
- package/src/hooks/hooks.js +257 -257
- package/src/stepDefinitions/API.steps.js +299 -299
- package/src/stepDefinitions/assertions.steps.js +861 -861
- package/src/stepDefinitions/browser.steps.js +7 -7
- package/src/stepDefinitions/frameActions.steps.js +76 -76
- package/src/stepDefinitions/keyboardActions.steps.js +226 -226
- package/src/stepDefinitions/mouseActions.steps.js +275 -275
- package/src/stepDefinitions/page.steps.js +71 -71
- package/src/stepDefinitions/random.steps.js +158 -158
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
function showHelp() {
|
|
2
|
-
console.log(`
|
|
3
|
-
🚀 Artes - Playwright Test Runner
|
|
4
|
-
|
|
5
|
-
Description:
|
|
6
|
-
Artes is a test runner for Playwright that executes Cucumber tests
|
|
7
|
-
and can generate Allure reports.
|
|
8
|
-
|
|
9
|
-
Usage:
|
|
10
|
-
npx artes [options]
|
|
11
|
-
|
|
12
|
-
Options:
|
|
13
|
-
🆘 -h, --help Show this help message
|
|
14
|
-
Usage: artes -h or artes --help
|
|
15
|
-
|
|
16
|
-
🏷️ -v, --version Show current version of artes
|
|
17
|
-
Usage: artes -v or artes --version
|
|
18
|
-
|
|
19
|
-
🏗️ -c, --create Create example project with artes
|
|
20
|
-
Usage: artes -c or artes --create
|
|
21
|
-
|
|
22
|
-
✅ -y, --yes Skip confirmation prompt for creating example project
|
|
23
|
-
Usage: artes -c -y or artes --create --yes
|
|
24
|
-
|
|
25
|
-
📊 -r, --report Run tests and generate Allure report
|
|
26
|
-
Usage: artes -r or artes --report
|
|
27
|
-
|
|
28
|
-
✅ --reportSuccess Generate screenshot and video record with also successful tests
|
|
29
|
-
Usage: artes --reportSuccess
|
|
30
|
-
|
|
31
|
-
⚡ --trace Enable tracing for all tests
|
|
32
|
-
Usage: artes --trace
|
|
33
|
-
|
|
34
|
-
🔍 -rwt, --reportWithTrace Include trace in the report
|
|
35
|
-
Usage: artes --reportWithTrace
|
|
36
|
-
|
|
37
|
-
📄 --singleFileReport Generate single file Allure report
|
|
38
|
-
Usage: artes -r --singleFileReport
|
|
39
|
-
|
|
40
|
-
🗜️ --zip Zip the report folder after generation
|
|
41
|
-
Usage: artes -r --zip
|
|
42
|
-
|
|
43
|
-
📁 --features Specify one or more feature files' relative paths to run (comma-separated)
|
|
44
|
-
Usage: artes --features "tests/features/Alma, tests/features/Banan.feature"
|
|
45
|
-
|
|
46
|
-
📜 --stepDef Specify one or more step definition files' relative paths to use (comma-separated)
|
|
47
|
-
Usage: artes --stepDef "tests/steps/login.js, tests/steps/home.js"
|
|
48
|
-
|
|
49
|
-
🔖 --tags Run tests with specified Cucumber tags
|
|
50
|
-
Usage: artes --tags "@smoke and not @wip"
|
|
51
|
-
|
|
52
|
-
🌐 --env Set environment for the test run
|
|
53
|
-
Usage: artes --env "dev"
|
|
54
|
-
|
|
55
|
-
🕶️ --headless Run browser in headless mode
|
|
56
|
-
Usage: artes --headless
|
|
57
|
-
|
|
58
|
-
⚡ --parallel Run tests in parallel mode
|
|
59
|
-
Usage: artes --parallel 3
|
|
60
|
-
|
|
61
|
-
🔁 --retry Retry failed tests
|
|
62
|
-
Usage: artes --retry 2
|
|
63
|
-
|
|
64
|
-
🎭 --dryRun Perform a dry run without executing tests
|
|
65
|
-
Usage: artes --dryRun
|
|
66
|
-
|
|
67
|
-
📈 --percentage Set minimum success percentage to pass test run
|
|
68
|
-
Usage: artes --percentage 85
|
|
69
|
-
|
|
70
|
-
🌐 --browser Specify browser to use (chromium, firefox, webkit)
|
|
71
|
-
Usage: artes --browser chromium
|
|
72
|
-
|
|
73
|
-
🌐 --baseURL Set base URL for the tests
|
|
74
|
-
Usage: artes --baseURL "https://example.com"
|
|
75
|
-
|
|
76
|
-
📏 --maxScreen Maximize browser window
|
|
77
|
-
Usage: artes --maxScreen
|
|
78
|
-
|
|
79
|
-
📐 --width Set browser width (default: 1280)
|
|
80
|
-
Usage: artes --width 1920
|
|
81
|
-
|
|
82
|
-
📏 --height Set browser height (default: 720)
|
|
83
|
-
Usage: artes --height 1080
|
|
84
|
-
|
|
85
|
-
⏱️ --timeout Set timeout for each test step (default: 30 seconds)
|
|
86
|
-
Usage: artes --timeout 10
|
|
87
|
-
|
|
88
|
-
🐢 --slowMo Slow down text execution for clear view (default: 0 seconds)
|
|
89
|
-
Usage: artes --slowMo 1
|
|
90
|
-
`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
module.exports = {
|
|
94
|
-
showHelp,
|
|
95
|
-
};
|
|
1
|
+
function showHelp() {
|
|
2
|
+
console.log(`
|
|
3
|
+
🚀 Artes - Playwright Test Runner
|
|
4
|
+
|
|
5
|
+
Description:
|
|
6
|
+
Artes is a test runner for Playwright that executes Cucumber tests
|
|
7
|
+
and can generate Allure reports.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
npx artes [options]
|
|
11
|
+
|
|
12
|
+
Options:
|
|
13
|
+
🆘 -h, --help Show this help message
|
|
14
|
+
Usage: artes -h or artes --help
|
|
15
|
+
|
|
16
|
+
🏷️ -v, --version Show current version of artes
|
|
17
|
+
Usage: artes -v or artes --version
|
|
18
|
+
|
|
19
|
+
🏗️ -c, --create Create example project with artes
|
|
20
|
+
Usage: artes -c or artes --create
|
|
21
|
+
|
|
22
|
+
✅ -y, --yes Skip confirmation prompt for creating example project
|
|
23
|
+
Usage: artes -c -y or artes --create --yes
|
|
24
|
+
|
|
25
|
+
📊 -r, --report Run tests and generate Allure report
|
|
26
|
+
Usage: artes -r or artes --report
|
|
27
|
+
|
|
28
|
+
✅ --reportSuccess Generate screenshot and video record with also successful tests
|
|
29
|
+
Usage: artes --reportSuccess
|
|
30
|
+
|
|
31
|
+
⚡ --trace Enable tracing for all tests
|
|
32
|
+
Usage: artes --trace
|
|
33
|
+
|
|
34
|
+
🔍 -rwt, --reportWithTrace Include trace in the report
|
|
35
|
+
Usage: artes --reportWithTrace
|
|
36
|
+
|
|
37
|
+
📄 --singleFileReport Generate single file Allure report
|
|
38
|
+
Usage: artes -r --singleFileReport
|
|
39
|
+
|
|
40
|
+
🗜️ --zip Zip the report folder after generation
|
|
41
|
+
Usage: artes -r --zip
|
|
42
|
+
|
|
43
|
+
📁 --features Specify one or more feature files' relative paths to run (comma-separated)
|
|
44
|
+
Usage: artes --features "tests/features/Alma, tests/features/Banan.feature"
|
|
45
|
+
|
|
46
|
+
📜 --stepDef Specify one or more step definition files' relative paths to use (comma-separated)
|
|
47
|
+
Usage: artes --stepDef "tests/steps/login.js, tests/steps/home.js"
|
|
48
|
+
|
|
49
|
+
🔖 --tags Run tests with specified Cucumber tags
|
|
50
|
+
Usage: artes --tags "@smoke and not @wip"
|
|
51
|
+
|
|
52
|
+
🌐 --env Set environment for the test run
|
|
53
|
+
Usage: artes --env "dev"
|
|
54
|
+
|
|
55
|
+
🕶️ --headless Run browser in headless mode
|
|
56
|
+
Usage: artes --headless
|
|
57
|
+
|
|
58
|
+
⚡ --parallel Run tests in parallel mode
|
|
59
|
+
Usage: artes --parallel 3
|
|
60
|
+
|
|
61
|
+
🔁 --retry Retry failed tests
|
|
62
|
+
Usage: artes --retry 2
|
|
63
|
+
|
|
64
|
+
🎭 --dryRun Perform a dry run without executing tests
|
|
65
|
+
Usage: artes --dryRun
|
|
66
|
+
|
|
67
|
+
📈 --percentage Set minimum success percentage to pass test run
|
|
68
|
+
Usage: artes --percentage 85
|
|
69
|
+
|
|
70
|
+
🌐 --browser Specify browser to use (chromium, firefox, webkit)
|
|
71
|
+
Usage: artes --browser chromium
|
|
72
|
+
|
|
73
|
+
🌐 --baseURL Set base URL for the tests
|
|
74
|
+
Usage: artes --baseURL "https://example.com"
|
|
75
|
+
|
|
76
|
+
📏 --maxScreen Maximize browser window
|
|
77
|
+
Usage: artes --maxScreen
|
|
78
|
+
|
|
79
|
+
📐 --width Set browser width (default: 1280)
|
|
80
|
+
Usage: artes --width 1920
|
|
81
|
+
|
|
82
|
+
📏 --height Set browser height (default: 720)
|
|
83
|
+
Usage: artes --height 1080
|
|
84
|
+
|
|
85
|
+
⏱️ --timeout Set timeout for each test step (default: 30 seconds)
|
|
86
|
+
Usage: artes --timeout 10
|
|
87
|
+
|
|
88
|
+
🐢 --slowMo Slow down text execution for clear view (default: 0 seconds)
|
|
89
|
+
Usage: artes --slowMo 1
|
|
90
|
+
`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = {
|
|
94
|
+
showHelp,
|
|
95
|
+
};
|
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const { execSync } = require("child_process");
|
|
6
|
-
|
|
7
|
-
function createProject(createYes) {
|
|
8
|
-
const projectDir = path.join(process.cwd(), "artes");
|
|
9
|
-
const srcDir = path.join(projectDir, "tests");
|
|
10
|
-
|
|
11
|
-
[
|
|
12
|
-
projectDir,
|
|
13
|
-
path.join(srcDir, "features"),
|
|
14
|
-
path.join(srcDir, "POMs"),
|
|
15
|
-
path.join(srcDir, "steps"),
|
|
16
|
-
path.join(projectDir, ".vscode"),
|
|
17
|
-
].forEach((dir) => fs.mkdirSync(dir, { recursive: true }));
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
console.log("🚀 Initializing project...");
|
|
21
|
-
execSync(`npm init ${createYes ? "-y" : ""}`, {cwd: projectDir, stdio: "inherit" });
|
|
22
|
-
execSync("npm i artes", {cwd: projectDir, stdio: "inherit" });
|
|
23
|
-
|
|
24
|
-
console.log("📦 Setting up browsers...");
|
|
25
|
-
execSync("npx playwright install", {cwd: projectDir, stdio: "inherit" });
|
|
26
|
-
|
|
27
|
-
const packageJsonPath = path.join(projectDir, "package.json");
|
|
28
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
29
|
-
|
|
30
|
-
if (packageJson.type) {
|
|
31
|
-
delete packageJson.type;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
packageJson.scripts = {
|
|
35
|
-
test: "npx artes",
|
|
36
|
-
testWithReport: "npx artes -r",
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
40
|
-
|
|
41
|
-
const config = `module.exports = {
|
|
42
|
-
headless: false, // Set to true for headless browser mode
|
|
43
|
-
|
|
44
|
-
// Configuration options:
|
|
45
|
-
// env: "", // string - Environment name for tests
|
|
46
|
-
// testPercentage: 0, // number - Minimum success rate percentage(Default: 0)
|
|
47
|
-
// baseURL: "", // string - Base URL for API tests
|
|
48
|
-
// paths: [], // string[] - Paths to feature files
|
|
49
|
-
// steps: "", // string - Step definitions files
|
|
50
|
-
// pomPath: "", // string - Path to POM files
|
|
51
|
-
// timeout : 0, // number - Test timeout in seconds
|
|
52
|
-
// slowMo: 0, // number - Slow down test execution (Default: 0 seconds)
|
|
53
|
-
// parallel: 0, // number - Number of parallel workers
|
|
54
|
-
// report: true / boolean - Generate report
|
|
55
|
-
// reportSuccess: false, // boolean - Add screenshots and video records to report also for success test cases
|
|
56
|
-
// trace: false, // boolean - Enable tracing
|
|
57
|
-
// reportWithTrace: false, // boolean - Include trace in report
|
|
58
|
-
// format: [], // string[] - Formatter names/paths
|
|
59
|
-
// formatOptions: {}, // object - Formatter options
|
|
60
|
-
// retry: 0, // number - Retry attempts for failing tests
|
|
61
|
-
// tags: "", // string - Tag expression to filter scenarios
|
|
62
|
-
// backtrace: false, // boolean - Show full backtrace for errors
|
|
63
|
-
// dryRun: false, // boolean - Prepare test run without execution
|
|
64
|
-
// browser: "chrome", // "chrome", "firefox", "webkit"
|
|
65
|
-
// width: 1280, // number - Browser width
|
|
66
|
-
// height: 720, // number - Browser height
|
|
67
|
-
// maximizeScreen: true // boolean - Maximize browser window
|
|
68
|
-
// forceExit: false, // boolean - Force process.exit() after tests
|
|
69
|
-
// failFast: false, // boolean - Stop on first test failure
|
|
70
|
-
// import: [], // string[] - Support code paths
|
|
71
|
-
// language: "en", // string - Default feature file language
|
|
72
|
-
// loader: [], // string[] - Module loader specifications
|
|
73
|
-
// name: [], // string[] - Run scenarios matching regex
|
|
74
|
-
// order: "defined", // string - Run order (defined/random)
|
|
75
|
-
// publish: false, // boolean - Publish to cucumber.io
|
|
76
|
-
// requireModule: [], // string[] - Transpilation module names
|
|
77
|
-
// retryTagFilter: "", // string - Tag expression for retries
|
|
78
|
-
// strict: true, // boolean - Fail on pending steps
|
|
79
|
-
// worldParameters: {} // object - World constructor parameters
|
|
80
|
-
};
|
|
81
|
-
`;
|
|
82
|
-
|
|
83
|
-
const featureContent = `Feature: Shopping on SauceDemo 🛒
|
|
84
|
-
|
|
85
|
-
Background: Login on SauceDemo
|
|
86
|
-
Given User is on home page of SauceDemo
|
|
87
|
-
And User types "standard_user" in "username_input"
|
|
88
|
-
And User types "secret_sauce" in "password_input"
|
|
89
|
-
And User clicks "#login-button"
|
|
90
|
-
|
|
91
|
-
Scenario Outline: Success Shopping
|
|
92
|
-
And User expects to be in "https://www.saucedemo.com/inventory.html" page
|
|
93
|
-
And User clicks "product_title"
|
|
94
|
-
And User clicks "add_to_cart_button"
|
|
95
|
-
And User clicks "cart_button"
|
|
96
|
-
Then User expects "item_price" should have "$29.99" text
|
|
97
|
-
|
|
98
|
-
Scenario Outline: Failed Shopping
|
|
99
|
-
And User expects to be in "https://www.saucedemo.com/inventory.html" page
|
|
100
|
-
And User clicks "product_title"
|
|
101
|
-
And User clicks "add_to_cart_button"
|
|
102
|
-
And User clicks "cart_button"
|
|
103
|
-
Then User expects "item_price" should not have "$29.99" text
|
|
104
|
-
|
|
105
|
-
`;
|
|
106
|
-
|
|
107
|
-
const pomContent = JSON.stringify(
|
|
108
|
-
{
|
|
109
|
-
username_input: { selector: "#user-name" },
|
|
110
|
-
password_input: "#password",
|
|
111
|
-
login_button: "#login-button",
|
|
112
|
-
product_title:
|
|
113
|
-
"xpath=/html/body/div/div/div/div[2]/div/div/div/div[1]/div[2]/div[1]/a/div",
|
|
114
|
-
add_to_cart_button: "#add-to-cart",
|
|
115
|
-
cart_button: ".shopping_cart_link",
|
|
116
|
-
item_price: ".inventory_item_price",
|
|
117
|
-
},
|
|
118
|
-
null,
|
|
119
|
-
2,
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
const stepsContent = `
|
|
123
|
-
const {Given,context} = require("artes");
|
|
124
|
-
|
|
125
|
-
// Example step definition
|
|
126
|
-
Given("User is on home page of SauceDemo", async () => {
|
|
127
|
-
await context.page.goto("https://www.saucedemo.com/");
|
|
128
|
-
});
|
|
129
|
-
`;
|
|
130
|
-
|
|
131
|
-
const hooksContent = `
|
|
132
|
-
export function BeforeStep() {
|
|
133
|
-
// hook for before each step
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function Before() {
|
|
137
|
-
// hook for before each test
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function BeforeAll() {
|
|
141
|
-
// hook for before all tests
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function AfterStep() {
|
|
145
|
-
// hook for after each step
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function After() {
|
|
149
|
-
// hook for after each test
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export function AfterAll() {
|
|
153
|
-
// hook for after all tests
|
|
154
|
-
}
|
|
155
|
-
`;
|
|
156
|
-
|
|
157
|
-
const vsCodeExtension = JSON.stringify({
|
|
158
|
-
recommendations: ["CucumberOpen.cucumber-official"],
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
const vsCodeSettings = JSON.stringify({
|
|
162
|
-
"cucumber.glue": [
|
|
163
|
-
"tests/steps/*.{ts,js}",
|
|
164
|
-
"node_modules/artes/src/stepDefinitions/*.{ts,js}",
|
|
165
|
-
],
|
|
166
|
-
"cucumber.features": ["tests/features/**/*.feature"],
|
|
167
|
-
"cucumberautocomplete.syncfeatures": true,
|
|
168
|
-
"cucumberautocomplete.strictGherkinCompletion": true,
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
console.log("📂 Creating project files...");
|
|
172
|
-
|
|
173
|
-
fs.writeFileSync(path.join(projectDir, "artes.config.js"), config, "utf-8");
|
|
174
|
-
fs.writeFileSync(
|
|
175
|
-
path.join(srcDir, "features", "example.feature"),
|
|
176
|
-
featureContent,
|
|
177
|
-
);
|
|
178
|
-
fs.writeFileSync(path.join(srcDir, "POMs", "example.pom.json"), pomContent);
|
|
179
|
-
fs.writeFileSync(path.join(srcDir, "steps", "common.steps.js"), stepsContent);
|
|
180
|
-
fs.writeFileSync(path.join(srcDir, "steps", "hooks.js"), hooksContent);
|
|
181
|
-
|
|
182
|
-
fs.writeFileSync(
|
|
183
|
-
path.join(projectDir, ".vscode", "settings.json"),
|
|
184
|
-
vsCodeSettings,
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
fs.writeFileSync(
|
|
188
|
-
path.join(projectDir, ".vscode", "extensions.json"),
|
|
189
|
-
vsCodeExtension,
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
console.log(`✨ Project created successfully in ${projectDir}!`);
|
|
193
|
-
console.log("Happy Testing 🎉");
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
module.exports = {
|
|
197
|
-
createProject,
|
|
198
|
-
};
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { execSync } = require("child_process");
|
|
6
|
+
|
|
7
|
+
function createProject(createYes) {
|
|
8
|
+
const projectDir = path.join(process.cwd(), "artes");
|
|
9
|
+
const srcDir = path.join(projectDir, "tests");
|
|
10
|
+
|
|
11
|
+
[
|
|
12
|
+
projectDir,
|
|
13
|
+
path.join(srcDir, "features"),
|
|
14
|
+
path.join(srcDir, "POMs"),
|
|
15
|
+
path.join(srcDir, "steps"),
|
|
16
|
+
path.join(projectDir, ".vscode"),
|
|
17
|
+
].forEach((dir) => fs.mkdirSync(dir, { recursive: true }));
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
console.log("🚀 Initializing project...");
|
|
21
|
+
execSync(`npm init ${createYes ? "-y" : ""}`, {cwd: projectDir, stdio: "inherit" });
|
|
22
|
+
execSync("npm i artes", {cwd: projectDir, stdio: "inherit" });
|
|
23
|
+
|
|
24
|
+
console.log("📦 Setting up browsers...");
|
|
25
|
+
execSync("npx playwright install", {cwd: projectDir, stdio: "inherit" });
|
|
26
|
+
|
|
27
|
+
const packageJsonPath = path.join(projectDir, "package.json");
|
|
28
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
29
|
+
|
|
30
|
+
if (packageJson.type) {
|
|
31
|
+
delete packageJson.type;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
packageJson.scripts = {
|
|
35
|
+
test: "npx artes",
|
|
36
|
+
testWithReport: "npx artes -r",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
40
|
+
|
|
41
|
+
const config = `module.exports = {
|
|
42
|
+
headless: false, // Set to true for headless browser mode
|
|
43
|
+
|
|
44
|
+
// Configuration options:
|
|
45
|
+
// env: "", // string - Environment name for tests
|
|
46
|
+
// testPercentage: 0, // number - Minimum success rate percentage(Default: 0)
|
|
47
|
+
// baseURL: "", // string - Base URL for API tests
|
|
48
|
+
// paths: [], // string[] - Paths to feature files
|
|
49
|
+
// steps: "", // string - Step definitions files
|
|
50
|
+
// pomPath: "", // string - Path to POM files
|
|
51
|
+
// timeout : 0, // number - Test timeout in seconds
|
|
52
|
+
// slowMo: 0, // number - Slow down test execution (Default: 0 seconds)
|
|
53
|
+
// parallel: 0, // number - Number of parallel workers
|
|
54
|
+
// report: true / boolean - Generate report
|
|
55
|
+
// reportSuccess: false, // boolean - Add screenshots and video records to report also for success test cases
|
|
56
|
+
// trace: false, // boolean - Enable tracing
|
|
57
|
+
// reportWithTrace: false, // boolean - Include trace in report
|
|
58
|
+
// format: [], // string[] - Formatter names/paths
|
|
59
|
+
// formatOptions: {}, // object - Formatter options
|
|
60
|
+
// retry: 0, // number - Retry attempts for failing tests
|
|
61
|
+
// tags: "", // string - Tag expression to filter scenarios
|
|
62
|
+
// backtrace: false, // boolean - Show full backtrace for errors
|
|
63
|
+
// dryRun: false, // boolean - Prepare test run without execution
|
|
64
|
+
// browser: "chrome", // "chrome", "firefox", "webkit"
|
|
65
|
+
// width: 1280, // number - Browser width
|
|
66
|
+
// height: 720, // number - Browser height
|
|
67
|
+
// maximizeScreen: true // boolean - Maximize browser window
|
|
68
|
+
// forceExit: false, // boolean - Force process.exit() after tests
|
|
69
|
+
// failFast: false, // boolean - Stop on first test failure
|
|
70
|
+
// import: [], // string[] - Support code paths
|
|
71
|
+
// language: "en", // string - Default feature file language
|
|
72
|
+
// loader: [], // string[] - Module loader specifications
|
|
73
|
+
// name: [], // string[] - Run scenarios matching regex
|
|
74
|
+
// order: "defined", // string - Run order (defined/random)
|
|
75
|
+
// publish: false, // boolean - Publish to cucumber.io
|
|
76
|
+
// requireModule: [], // string[] - Transpilation module names
|
|
77
|
+
// retryTagFilter: "", // string - Tag expression for retries
|
|
78
|
+
// strict: true, // boolean - Fail on pending steps
|
|
79
|
+
// worldParameters: {} // object - World constructor parameters
|
|
80
|
+
};
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
const featureContent = `Feature: Shopping on SauceDemo 🛒
|
|
84
|
+
|
|
85
|
+
Background: Login on SauceDemo
|
|
86
|
+
Given User is on home page of SauceDemo
|
|
87
|
+
And User types "standard_user" in "username_input"
|
|
88
|
+
And User types "secret_sauce" in "password_input"
|
|
89
|
+
And User clicks "#login-button"
|
|
90
|
+
|
|
91
|
+
Scenario Outline: Success Shopping
|
|
92
|
+
And User expects to be in "https://www.saucedemo.com/inventory.html" page
|
|
93
|
+
And User clicks "product_title"
|
|
94
|
+
And User clicks "add_to_cart_button"
|
|
95
|
+
And User clicks "cart_button"
|
|
96
|
+
Then User expects "item_price" should have "$29.99" text
|
|
97
|
+
|
|
98
|
+
Scenario Outline: Failed Shopping
|
|
99
|
+
And User expects to be in "https://www.saucedemo.com/inventory.html" page
|
|
100
|
+
And User clicks "product_title"
|
|
101
|
+
And User clicks "add_to_cart_button"
|
|
102
|
+
And User clicks "cart_button"
|
|
103
|
+
Then User expects "item_price" should not have "$29.99" text
|
|
104
|
+
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
const pomContent = JSON.stringify(
|
|
108
|
+
{
|
|
109
|
+
username_input: { selector: "#user-name" },
|
|
110
|
+
password_input: "#password",
|
|
111
|
+
login_button: "#login-button",
|
|
112
|
+
product_title:
|
|
113
|
+
"xpath=/html/body/div/div/div/div[2]/div/div/div/div[1]/div[2]/div[1]/a/div",
|
|
114
|
+
add_to_cart_button: "#add-to-cart",
|
|
115
|
+
cart_button: ".shopping_cart_link",
|
|
116
|
+
item_price: ".inventory_item_price",
|
|
117
|
+
},
|
|
118
|
+
null,
|
|
119
|
+
2,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const stepsContent = `
|
|
123
|
+
const {Given,context} = require("artes");
|
|
124
|
+
|
|
125
|
+
// Example step definition
|
|
126
|
+
Given("User is on home page of SauceDemo", async () => {
|
|
127
|
+
await context.page.goto("https://www.saucedemo.com/");
|
|
128
|
+
});
|
|
129
|
+
`;
|
|
130
|
+
|
|
131
|
+
const hooksContent = `
|
|
132
|
+
export function BeforeStep() {
|
|
133
|
+
// hook for before each step
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function Before() {
|
|
137
|
+
// hook for before each test
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function BeforeAll() {
|
|
141
|
+
// hook for before all tests
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function AfterStep() {
|
|
145
|
+
// hook for after each step
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function After() {
|
|
149
|
+
// hook for after each test
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function AfterAll() {
|
|
153
|
+
// hook for after all tests
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
|
|
157
|
+
const vsCodeExtension = JSON.stringify({
|
|
158
|
+
recommendations: ["CucumberOpen.cucumber-official"],
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const vsCodeSettings = JSON.stringify({
|
|
162
|
+
"cucumber.glue": [
|
|
163
|
+
"tests/steps/*.{ts,js}",
|
|
164
|
+
"node_modules/artes/src/stepDefinitions/*.{ts,js}",
|
|
165
|
+
],
|
|
166
|
+
"cucumber.features": ["tests/features/**/*.feature"],
|
|
167
|
+
"cucumberautocomplete.syncfeatures": true,
|
|
168
|
+
"cucumberautocomplete.strictGherkinCompletion": true,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
console.log("📂 Creating project files...");
|
|
172
|
+
|
|
173
|
+
fs.writeFileSync(path.join(projectDir, "artes.config.js"), config, "utf-8");
|
|
174
|
+
fs.writeFileSync(
|
|
175
|
+
path.join(srcDir, "features", "example.feature"),
|
|
176
|
+
featureContent,
|
|
177
|
+
);
|
|
178
|
+
fs.writeFileSync(path.join(srcDir, "POMs", "example.pom.json"), pomContent);
|
|
179
|
+
fs.writeFileSync(path.join(srcDir, "steps", "common.steps.js"), stepsContent);
|
|
180
|
+
fs.writeFileSync(path.join(srcDir, "steps", "hooks.js"), hooksContent);
|
|
181
|
+
|
|
182
|
+
fs.writeFileSync(
|
|
183
|
+
path.join(projectDir, ".vscode", "settings.json"),
|
|
184
|
+
vsCodeSettings,
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
fs.writeFileSync(
|
|
188
|
+
path.join(projectDir, ".vscode", "extensions.json"),
|
|
189
|
+
vsCodeExtension,
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
console.log(`✨ Project created successfully in ${projectDir}!`);
|
|
193
|
+
console.log("Happy Testing 🎉");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
module.exports = {
|
|
197
|
+
createProject,
|
|
198
|
+
};
|