artes 1.7.4 → 1.7.6

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.
Files changed (48) hide show
  1. package/README.md +781 -779
  2. package/assets/styles.css +4 -4
  3. package/cucumber.config.js +253 -253
  4. package/docs/ciExecutors.md +198 -198
  5. package/docs/emulationDevicesList.md +152 -152
  6. package/docs/functionDefinitions.md +2401 -2401
  7. package/docs/stepDefinitions.md +435 -433
  8. package/executer.js +266 -264
  9. package/index.js +50 -50
  10. package/package.json +56 -56
  11. package/src/helper/contextManager/browserManager.js +74 -74
  12. package/src/helper/contextManager/requestManager.js +23 -23
  13. package/src/helper/controller/elementController.js +210 -210
  14. package/src/helper/controller/findDuplicateTestNames.js +69 -69
  15. package/src/helper/controller/getEnvInfo.js +94 -94
  16. package/src/helper/controller/getExecutor.js +109 -109
  17. package/src/helper/controller/pomCollector.js +83 -83
  18. package/src/helper/controller/reportCustomizer.js +485 -485
  19. package/src/helper/controller/screenComparer.js +97 -108
  20. package/src/helper/controller/status-formatter.js +137 -137
  21. package/src/helper/controller/testCoverageCalculator.js +111 -111
  22. package/src/helper/executers/cleaner.js +23 -23
  23. package/src/helper/executers/exporter.js +19 -19
  24. package/src/helper/executers/helper.js +193 -191
  25. package/src/helper/executers/projectCreator.js +226 -222
  26. package/src/helper/executers/reportGenerator.js +91 -91
  27. package/src/helper/executers/testRunner.js +28 -28
  28. package/src/helper/executers/versionChecker.js +31 -31
  29. package/src/helper/imports/commons.js +65 -65
  30. package/src/helper/stepFunctions/APIActions.js +495 -495
  31. package/src/helper/stepFunctions/assertions.js +986 -986
  32. package/src/helper/stepFunctions/browserActions.js +87 -87
  33. package/src/helper/stepFunctions/elementInteractions.js +60 -60
  34. package/src/helper/stepFunctions/exporter.js +19 -19
  35. package/src/helper/stepFunctions/frameActions.js +72 -72
  36. package/src/helper/stepFunctions/keyboardActions.js +66 -66
  37. package/src/helper/stepFunctions/mouseActions.js +84 -84
  38. package/src/helper/stepFunctions/pageActions.js +43 -43
  39. package/src/hooks/context.js +15 -15
  40. package/src/hooks/hooks.js +287 -279
  41. package/src/stepDefinitions/API.steps.js +310 -310
  42. package/src/stepDefinitions/assertions.steps.js +1303 -1280
  43. package/src/stepDefinitions/browser.steps.js +74 -74
  44. package/src/stepDefinitions/frameActions.steps.js +76 -76
  45. package/src/stepDefinitions/keyboardActions.steps.js +264 -264
  46. package/src/stepDefinitions/mouseActions.steps.js +378 -378
  47. package/src/stepDefinitions/page.steps.js +71 -71
  48. package/src/stepDefinitions/random.steps.js +191 -191
@@ -1,222 +1,226 @@
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, noDeps) {
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
- console.log("🚀 Initializing project...");
20
- execSync(`npm init ${createYes ? "-y" : ""}`, {
21
- cwd: projectDir,
22
- stdio: "inherit",
23
- });
24
-
25
- if (!noDeps) {
26
- execSync("npm i artes@latest", { cwd: projectDir, stdio: "inherit" });
27
- console.log("📦 Setting up browsers...");
28
- execSync("npx playwright install", { cwd: projectDir, stdio: "inherit" });
29
- }
30
-
31
- const packageJsonPath = path.join(projectDir, "package.json");
32
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
33
-
34
- if (packageJson.type) {
35
- delete packageJson.type;
36
- }
37
-
38
- packageJson.scripts = {
39
- test: "npx artes",
40
- testWithReport: "npx artes -r",
41
- };
42
-
43
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
44
-
45
- const config = `module.exports = {
46
- // Configuration options:
47
- // headless: false, // Set to true for headless browser mode
48
- // env: "", // string - Environment name for tests
49
- // variables: {} // object - Variables for tests
50
- // testPercentage: 0, // number - Minimum success rate percentage(Default: 0)
51
- // baseURL: "", // string - Base URL for API tests
52
- // paths: [], // string[] - Paths to feature files
53
- // steps: "", // string - Step definitions files
54
- // pomPath: "", // string - Path to POM files
55
- // ai: {
56
- // ai: false, // boolean - Enable AI-generated bug reports and test summaries
57
- // url: "", // string - Local AI endpoint URL (e.g., Ollama, LM Studio). Overrides model/key when set
58
- // model: "gemini 2.5 flash", // string - AI model to use (e.g., "gpt-4o", "gemini 2.5 flash", "claude sonnet", "mistral large")
59
- // key: "", // string - API key for the selected AI provider
60
- // language: "English", // string - Language for generated reports (e.g., "English", "Azerbaijani"),
61
- // maxTokens: 4000, // number - Maximum tokens for AI-generated reports (default: 4000)
62
- // maxReports: 10, // number - Maximum number of AI reports to generate per test run
63
- // },
64
- // timeout : 0, // number - Test timeout in seconds
65
- // slowMo: 0, // number - Slow down test execution (Default: 0 seconds)
66
- // parallel: 0, // number - Number of parallel workers
67
- // report: true, // boolean - Generate report
68
- // zip: false, // boolean - Generate zip of report
69
- // uploadReport: false, // boolean - Upload report to Artes Reporting System
70
- // reporterURL: "", // string - URL of the Artes Reporting System
71
- // projectName: "Artes Report", // string - Name of the project in the Artes Reporting System
72
- // projectType: "Artes", // string - Type/category of the project (e.g., UI, API)
73
- // reportPath: "./report.zip", // string - Path to the report zip file to be uploaded
74
- // logo: "", // string - Custom logo for the report sidebar. Accepts an absolute path, a relative path, or a direct image URL
75
- // brandName: "", // string - Brand name displayed next to the logo in the report sidebar
76
- // reportName: "Artes Report", // string - Report name displayed on the summary widget and in the Artes Reporting System
77
- // reportSuccess: false, // boolean - Add screenshots and video records to report also for success test cases
78
- // trace: false, // boolean - Enable tracing
79
- // reportWithTrace: false, // boolean - Include trace in report
80
- // format: [], // string[] - Formatter names/paths
81
- // formatOptions: {}, // object - Formatter options
82
- // retry: 0, // number - Retry attempts for failing tests
83
- // tags: "", // string - Tag expression to filter scenarios
84
- // backtrace: false, // boolean - Show full backtrace for errors
85
- // dryRun: false, // boolean - Prepare test run without execution
86
- // browser: "chrome", // "chrome", "firefox", "webkit"
87
- // offline: false, // boolean - Run browser in offline mode
88
- // device: "", // string - Emulate specific device (e.g., "iPhone 13", for more devices look at the documentation)
89
- // width: 1280, // number - Browser width
90
- // height: 720, // number - Browser height
91
- // maximizeScreen: true // boolean - Maximize browser window
92
- // forceExit: false, // boolean - Force process.exit() after tests
93
- // failFast: false, // boolean - Stop on first test failure
94
- // import: [], // string[] - Support code paths
95
- // language: "en", // string - Default feature file language
96
- // loader: [], // string[] - Module loader specifications
97
- // name: [], // string[] - Run scenarios matching regex
98
- // order: "defined", // string - Run order (defined/random)
99
- // publish: false, // boolean - Publish to cucumber.io
100
- // requireModule: [], // string[] - Transpilation module names
101
- // retryTagFilter: "", // string - Tag expression for retries
102
- // strict: true, // boolean - Fail on pending steps
103
- // worldParameters: {} // object - World constructor parameters
104
- };
105
- `;
106
-
107
- const featureContent = `Feature: Shopping on SauceDemo 🛒
108
-
109
- Background: Login on SauceDemo
110
- Given User is on home page of SauceDemo
111
- And User types "standard_user" in "username_input"
112
- And User types "secret_sauce" in "password_input"
113
- And User clicks "#login-button"
114
-
115
- Scenario Outline: Success Shopping
116
- And User expects to be in "https://www.saucedemo.com/inventory.html" page
117
- And User clicks "product_title"
118
- And User clicks "add_to_cart_button"
119
- And User clicks "cart_button"
120
- Then User expects "item_price" should have "$29.99" text
121
-
122
- Scenario Outline: Failed Shopping
123
- And User expects to be in "https://www.saucedemo.com/inventory.html" page
124
- And User clicks "product_title"
125
- And User clicks "add_to_cart_button"
126
- And User clicks "cart_button"
127
- Then User expects "item_price" should not have "$29.99" text
128
-
129
- `;
130
-
131
- const pomContent = JSON.stringify(
132
- {
133
- username_input: { selector: "#user-name" },
134
- password_input: "#password",
135
- login_button: "#login-button",
136
- product_title:
137
- "xpath=/html/body/div/div/div/div[2]/div/div/div/div[1]/div[2]/div[1]/a/div",
138
- add_to_cart_button: "#add-to-cart",
139
- cart_button: ".shopping_cart_link",
140
- item_price: ".inventory_item_price",
141
- },
142
- null,
143
- 2,
144
- );
145
-
146
- const stepsContent = `
147
- const {Given,context} = require("artes");
148
-
149
- // Example step definition
150
- Given("User is on home page of SauceDemo", async () => {
151
- await context.page.goto("https://www.saucedemo.com/");
152
- });
153
- `;
154
-
155
- const hooksContent = `
156
- export function BeforeStep() {
157
- // hook for before each step
158
- }
159
-
160
- export function Before() {
161
- // hook for before each test
162
- }
163
-
164
- export function BeforeAll() {
165
- // hook for before all tests
166
- }
167
-
168
- export function AfterStep() {
169
- // hook for after each step
170
- }
171
-
172
- export function After() {
173
- // hook for after each test
174
- }
175
-
176
- export function AfterAll() {
177
- // hook for after all tests
178
- }
179
- `;
180
-
181
- const vsCodeExtension = JSON.stringify({
182
- recommendations: ["CucumberOpen.cucumber-official"],
183
- });
184
-
185
- const vsCodeSettings = JSON.stringify({
186
- "cucumber.glue": [
187
- "tests/steps/*.{ts,js}",
188
- "node_modules/artes/src/stepDefinitions/*.{ts,js}",
189
- ],
190
- "cucumber.features": ["tests/features/**/*.feature"],
191
- "cucumberautocomplete.syncfeatures": true,
192
- "cucumberautocomplete.strictGherkinCompletion": true,
193
- });
194
-
195
- console.log("📂 Creating project files...");
196
-
197
- fs.writeFileSync(path.join(projectDir, "artes.config.js"), config, "utf-8");
198
- fs.writeFileSync(
199
- path.join(srcDir, "features", "example.feature"),
200
- featureContent,
201
- );
202
- fs.writeFileSync(path.join(srcDir, "POMs", "example.pom.json"), pomContent);
203
- fs.writeFileSync(path.join(srcDir, "steps", "common.steps.js"), stepsContent);
204
- fs.writeFileSync(path.join(srcDir, "steps", "hooks.js"), hooksContent);
205
-
206
- fs.writeFileSync(
207
- path.join(projectDir, ".vscode", "settings.json"),
208
- vsCodeSettings,
209
- );
210
-
211
- fs.writeFileSync(
212
- path.join(projectDir, ".vscode", "extensions.json"),
213
- vsCodeExtension,
214
- );
215
-
216
- console.log(`✨ Project created successfully in ${projectDir}!`);
217
- console.log("Happy Testing 🎉");
218
- }
219
-
220
- module.exports = {
221
- createProject,
222
- };
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, noDeps) {
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
+ console.log("🚀 Initializing project...");
20
+ execSync(`npm init ${createYes ? "-y" : ""}`, {
21
+ cwd: projectDir,
22
+ stdio: "inherit",
23
+ });
24
+
25
+ if (!noDeps) {
26
+ execSync("npm i artes@latest", { cwd: projectDir, stdio: "inherit" });
27
+ console.log("📦 Setting up browsers...");
28
+ execSync("npx playwright install", { cwd: projectDir, stdio: "inherit" });
29
+ }
30
+
31
+ const packageJsonPath = path.join(projectDir, "package.json");
32
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
33
+
34
+ if (packageJson.type) {
35
+ delete packageJson.type;
36
+ }
37
+
38
+ packageJson.scripts = {
39
+ test: "npx artes",
40
+ testWithReport: "npx artes -r",
41
+ };
42
+
43
+ packageJson.dependencies = {
44
+ artes: "latest"
45
+ };
46
+
47
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
48
+
49
+ const config = `module.exports = {
50
+ // Configuration options:
51
+ // headless: false, // Set to true for headless browser mode
52
+ // env: "", // string - Environment name for tests
53
+ // variables: {} // object - Variables for tests
54
+ // testPercentage: 0, // number - Minimum success rate percentage(Default: 0)
55
+ // baseURL: "", // string - Base URL for API tests
56
+ // paths: [], // string[] - Paths to feature files
57
+ // steps: "", // string - Step definitions files
58
+ // pomPath: "", // string - Path to POM files
59
+ // ai: {
60
+ // ai: false, // boolean - Enable AI-generated bug reports and test summaries
61
+ // url: "", // string - Local AI endpoint URL (e.g., Ollama, LM Studio). Overrides model/key when set
62
+ // model: "gemini 2.5 flash", // string - AI model to use (e.g., "gpt-4o", "gemini 2.5 flash", "claude sonnet", "mistral large")
63
+ // key: "", // string - API key for the selected AI provider
64
+ // language: "English", // string - Language for generated reports (e.g., "English", "Azerbaijani"),
65
+ // maxTokens: 4000, // number - Maximum tokens for AI-generated reports (default: 4000)
66
+ // maxReports: 10, // number - Maximum number of AI reports to generate per test run
67
+ // },
68
+ // timeout : 0, // number - Test timeout in seconds
69
+ // slowMo: 0, // number - Slow down test execution (Default: 0 seconds)
70
+ // parallel: 0, // number - Number of parallel workers
71
+ // report: true, // boolean - Generate report
72
+ // zip: false, // boolean - Generate zip of report
73
+ // uploadReport: false, // boolean - Upload report to Artes Reporting System
74
+ // reporterURL: "", // string - URL of the Artes Reporting System
75
+ // projectName: "Artes Report", // string - Name of the project in the Artes Reporting System
76
+ // projectType: "Artes", // string - Type/category of the project (e.g., UI, API)
77
+ // reportPath: "./report.zip", // string - Path to the report zip file to be uploaded
78
+ // logo: "", // string - Custom logo for the report sidebar. Accepts an absolute path, a relative path, or a direct image URL
79
+ // brandName: "", // string - Brand name displayed next to the logo in the report sidebar
80
+ // reportName: "Artes Report", // string - Report name displayed on the summary widget and in the Artes Reporting System
81
+ // reportSuccess: false, // boolean - Add screenshots and video records to report also for success test cases
82
+ // trace: false, // boolean - Enable tracing
83
+ // reportWithTrace: false, // boolean - Include trace in report
84
+ // format: [], // string[] - Formatter names/paths
85
+ // formatOptions: {}, // object - Formatter options
86
+ // retry: 0, // number - Retry attempts for failing tests
87
+ // tags: "", // string - Tag expression to filter scenarios
88
+ // backtrace: false, // boolean - Show full backtrace for errors
89
+ // dryRun: false, // boolean - Prepare test run without execution
90
+ // browser: "chrome", // "chrome", "firefox", "webkit"
91
+ // offline: false, // boolean - Run browser in offline mode
92
+ // device: "", // string - Emulate specific device (e.g., "iPhone 13", for more devices look at the documentation)
93
+ // width: 1280, // number - Browser width
94
+ // height: 720, // number - Browser height
95
+ // maximizeScreen: true // boolean - Maximize browser window
96
+ // forceExit: false, // boolean - Force process.exit() after tests
97
+ // failFast: false, // boolean - Stop on first test failure
98
+ // import: [], // string[] - Support code paths
99
+ // language: "en", // string - Default feature file language
100
+ // loader: [], // string[] - Module loader specifications
101
+ // name: [], // string[] - Run scenarios matching regex
102
+ // order: "defined", // string - Run order (defined/random)
103
+ // publish: false, // boolean - Publish to cucumber.io
104
+ // requireModule: [], // string[] - Transpilation module names
105
+ // retryTagFilter: "", // string - Tag expression for retries
106
+ // strict: true, // boolean - Fail on pending steps
107
+ // worldParameters: {} // object - World constructor parameters
108
+ };
109
+ `;
110
+
111
+ const featureContent = `Feature: Shopping on SauceDemo 🛒
112
+
113
+ Background: Login on SauceDemo
114
+ Given User is on home page of SauceDemo
115
+ And User types "standard_user" in "username_input"
116
+ And User types "secret_sauce" in "password_input"
117
+ And User clicks "#login-button"
118
+
119
+ Scenario Outline: Success Shopping
120
+ And User expects to be in "https://www.saucedemo.com/inventory.html" page
121
+ And User clicks "product_title"
122
+ And User clicks "add_to_cart_button"
123
+ And User clicks "cart_button"
124
+ Then User expects "item_price" should have "$29.99" text
125
+
126
+ Scenario Outline: Failed Shopping
127
+ And User expects to be in "https://www.saucedemo.com/inventory.html" page
128
+ And User clicks "product_title"
129
+ And User clicks "add_to_cart_button"
130
+ And User clicks "cart_button"
131
+ Then User expects "item_price" should not have "$29.99" text
132
+
133
+ `;
134
+
135
+ const pomContent = JSON.stringify(
136
+ {
137
+ username_input: { selector: "#user-name" },
138
+ password_input: "#password",
139
+ login_button: "#login-button",
140
+ product_title:
141
+ "xpath=/html/body/div/div/div/div[2]/div/div/div/div[1]/div[2]/div[1]/a/div",
142
+ add_to_cart_button: "#add-to-cart",
143
+ cart_button: ".shopping_cart_link",
144
+ item_price: ".inventory_item_price",
145
+ },
146
+ null,
147
+ 2,
148
+ );
149
+
150
+ const stepsContent = `
151
+ const {Given,context} = require("artes");
152
+
153
+ // Example step definition
154
+ Given("User is on home page of SauceDemo", async () => {
155
+ await context.page.goto("https://www.saucedemo.com/");
156
+ });
157
+ `;
158
+
159
+ const hooksContent = `
160
+ export function BeforeStep() {
161
+ // hook for before each step
162
+ }
163
+
164
+ export function Before() {
165
+ // hook for before each test
166
+ }
167
+
168
+ export function BeforeAll() {
169
+ // hook for before all tests
170
+ }
171
+
172
+ export function AfterStep() {
173
+ // hook for after each step
174
+ }
175
+
176
+ export function After() {
177
+ // hook for after each test
178
+ }
179
+
180
+ export function AfterAll() {
181
+ // hook for after all tests
182
+ }
183
+ `;
184
+
185
+ const vsCodeExtension = JSON.stringify({
186
+ recommendations: ["CucumberOpen.cucumber-official"],
187
+ });
188
+
189
+ const vsCodeSettings = JSON.stringify({
190
+ "cucumber.glue": [
191
+ "tests/steps/*.{ts,js}",
192
+ "node_modules/artes/src/stepDefinitions/*.{ts,js}",
193
+ ],
194
+ "cucumber.features": ["tests/features/**/*.feature"],
195
+ "cucumberautocomplete.syncfeatures": true,
196
+ "cucumberautocomplete.strictGherkinCompletion": true,
197
+ });
198
+
199
+ console.log("📂 Creating project files...");
200
+
201
+ fs.writeFileSync(path.join(projectDir, "artes.config.js"), config, "utf-8");
202
+ fs.writeFileSync(
203
+ path.join(srcDir, "features", "example.feature"),
204
+ featureContent,
205
+ );
206
+ fs.writeFileSync(path.join(srcDir, "POMs", "example.pom.json"), pomContent);
207
+ fs.writeFileSync(path.join(srcDir, "steps", "common.steps.js"), stepsContent);
208
+ fs.writeFileSync(path.join(srcDir, "steps", "hooks.js"), hooksContent);
209
+
210
+ fs.writeFileSync(
211
+ path.join(projectDir, ".vscode", "settings.json"),
212
+ vsCodeSettings,
213
+ );
214
+
215
+ fs.writeFileSync(
216
+ path.join(projectDir, ".vscode", "extensions.json"),
217
+ vsCodeExtension,
218
+ );
219
+
220
+ console.log(`✨ Project created successfully in ${projectDir}!`);
221
+ console.log("Happy Testing 🎉");
222
+ }
223
+
224
+ module.exports = {
225
+ createProject,
226
+ };