artes 1.4.8 โ†’ 1.4.9

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 (40) hide show
  1. package/README.md +668 -668
  2. package/cucumber.config.js +223 -223
  3. package/docs/emulationDevicesList.md +152 -152
  4. package/docs/functionDefinitions.md +2401 -2401
  5. package/docs/stepDefinitions.md +402 -402
  6. package/executer.js +479 -478
  7. package/index.js +50 -50
  8. package/package.json +52 -52
  9. package/src/helper/contextManager/browserManager.js +74 -74
  10. package/src/helper/contextManager/requestManager.js +23 -23
  11. package/src/helper/controller/elementController.js +203 -203
  12. package/src/helper/controller/pomCollector.js +82 -82
  13. package/src/helper/executers/cleaner.js +19 -19
  14. package/src/helper/executers/exporter.js +15 -15
  15. package/src/helper/executers/helper.js +110 -110
  16. package/src/helper/executers/projectCreator.js +206 -206
  17. package/src/helper/executers/reportGenerator.js +70 -70
  18. package/src/helper/executers/testRunner.js +28 -28
  19. package/src/helper/executers/versionChecker.js +31 -31
  20. package/src/helper/imports/commons.js +57 -57
  21. package/src/helper/stepFunctions/APIActions.js +495 -495
  22. package/src/helper/stepFunctions/assertions.js +989 -989
  23. package/src/helper/stepFunctions/browserActions.js +22 -22
  24. package/src/helper/stepFunctions/elementInteractions.js +60 -60
  25. package/src/helper/stepFunctions/exporter.js +19 -19
  26. package/src/helper/stepFunctions/frameActions.js +72 -72
  27. package/src/helper/stepFunctions/keyboardActions.js +66 -66
  28. package/src/helper/stepFunctions/mouseActions.js +83 -83
  29. package/src/helper/stepFunctions/pageActions.js +43 -43
  30. package/src/hooks/context.js +15 -15
  31. package/src/hooks/hooks.js +215 -236
  32. package/src/stepDefinitions/API.steps.js +310 -310
  33. package/src/stepDefinitions/assertions.steps.js +1092 -1092
  34. package/src/stepDefinitions/browser.steps.js +7 -7
  35. package/src/stepDefinitions/frameActions.steps.js +76 -76
  36. package/src/stepDefinitions/keyboardActions.steps.js +265 -265
  37. package/src/stepDefinitions/mouseActions.steps.js +378 -378
  38. package/src/stepDefinitions/page.steps.js +71 -71
  39. package/src/stepDefinitions/random.steps.js +188 -188
  40. package/status-formatter.js +138 -138
package/README.md CHANGED
@@ -1,668 +1,668 @@
1
- <p align="center">
2
- <img alt="artesLogo" src="https://github.com/user-attachments/assets/e0641011-0e96-4330-8ad5-935b395b0838" width="280">
3
- </p>
4
-
5
- <h1 align="center">Artes</h1>
6
-
7
- ## ๐Ÿš€ Summary
8
-
9
- Artes is a test runner for Playwright that executes [predefined Cucumber tests](./docs/stepDefinitions.md) and can generate Allure reports for test results. It simplifies setting up Playwright with Cucumber in your automation workflow. With Artes, you can easily run tests without writing step definitions, generate reports, and customize your testing environment.
10
-
11
- ![artes demonstration](https://github.com/user-attachments/assets/c46172f7-103d-45d1-a37d-8d4267df0967)
12
-
13
- ---
14
-
15
- ## ๐ŸŒŸ Artes Benefits
16
-
17
- ### ๐Ÿš€ Fast Setup & Smooth Onboarding
18
-
19
- - Install in minutes and create a test project effortlessly
20
- - Well-structured, easy-to-follow documentation for a smooth learning curve
21
- - Designed for long-term maintainability and scalability
22
-
23
- ### ๐Ÿงฉ Powerful & Developer-Friendly Architecture
24
-
25
- - Intuitive API for writing custom step definitions
26
- - Rich set of ready-to-use step definitions to speed up test creation
27
- - Fully extensible โ€” add your own step definitions anytime
28
-
29
- ### ๐ŸŒ Advanced API Testing
30
-
31
- - Schema validation to ensure API response correctness
32
- - Rich assertion library for precise validations
33
- - Support for all HTTP methods
34
- - Environment-based API configuration for flexible testing
35
-
36
- ### ๐Ÿ” Smart Variable & Data Handling
37
-
38
- - Page Object Model (POM) support for structured data management
39
- - Save, reuse, and share variables across steps
40
- - Built-in data randomization for dynamic and realistic test data
41
- - Environment-specific variables for clean environment separation
42
-
43
- ### ๐Ÿ–ฅ๏ธ Modern UI Automation
44
-
45
- - Wide locator strategy support (CSS, XPath, text-based, and more)
46
- - Built-in browser actions
47
- - Cookie management
48
- - Local & session storage handling
49
-
50
- ### โš™๏ธ Flexible Configuration & Hooks
51
-
52
- - Environment-based configuration system
53
- - Powerful and customizable configuration files
54
- - Full hook support:
55
- - Before / After
56
- - Step-level and scenario-level hooks
57
-
58
- ### ๐Ÿงช CLI, CI/CD & Containerization
59
-
60
- - Powerful CLI for full control from the command line
61
- - Official [Artes Docker image](https://hub.docker.com/r/vahidaghayev/artes) for seamless containerized execution
62
- - CI/CD-ready โ€” integrate easily with any pipeline
63
-
64
- ### ๐Ÿ“Š Artes Reporting System
65
-
66
- - Easy installation with docker compose (For detailed info: [Artes Reporting System](https://github.com/4gayev1/artes-reporting-system))
67
- - Multiple reporting formats supported
68
- - Native Allure reporting integration
69
- - Customizable Artes Reporting System
70
-
71
- ---
72
-
73
- ## ๐Ÿง‘โ€๐Ÿ’ป Installation
74
-
75
- You can install **Artes** via npm. To install it globally **(RECOMMENDED)**, run the following command:
76
-
77
- ```bash
78
- npm install -g artes
79
- ```
80
-
81
- To install it locally in your project, run:
82
-
83
- ```bash
84
- npm install artes
85
- ```
86
-
87
- Once installed, you can run **Artes** using:
88
-
89
- ```bash
90
- npx artes [options]
91
- ```
92
-
93
- ---
94
-
95
- ## ๐Ÿ’ก Usage
96
-
97
- **Artes** has following CLI options:
98
-
99
- ```bash
100
- npx artes [options]
101
- ```
102
-
103
- ### Options
104
-
105
- | Option | Description | Usage Example |
106
- | ------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
107
- | ๐Ÿ†˜ `-h, --help` | Show the usage options | `artes -h` or `artes --help` |
108
- | ๐Ÿท๏ธ `-v, --version` | Show the current version of Artes | `artes -v` or `artes --version` |
109
- | ๐Ÿ—๏ธ `-c, --create` | Create an example project with Artes | `artes -c` or `artes --create` |
110
- | โœ… `-y, --yes` | Skip the confirmation prompt when creating an example project | `artes -c -y` or `artes --create --yes` |
111
- | ๐Ÿšซ --noDeps | Skip installing dependencies when creating example project | `artes -c --noDeps` |
112
- | ๐Ÿ“Š `-r, --report` | Run tests and generate Allure report | `artes -r` or `artes --report` |
113
- | `--reportSuccess` | Add screenshots and video records for also Success test cases | `artes --reportSuccess` |
114
- | `--trace` | Enable tracing | `artes --trace` |
115
- | `-rwt, --reportWithTrace` | Add trace to the report | `artes -rwt` or `artes --reportWithTrace` |
116
- | `--singleFileReport` | Generate single file allure report | `artes -r --singleFileReport` |
117
- | `--zip` | Zip the report folder after generation | `artes -r --zip` |
118
- | ๐Ÿ“ `--features` | Specify one or more feature files' relative paths to run (comma-separated) | `artes --features "tests/features/Alma,tests/features/Banan.feature"` |
119
- | ๐Ÿ“œ `--stepDef` | Specify one or more step definition files' relative paths to use (comma-separated) | `artes --stepDef "tests/steps/login.js,tests/steps/home.js"` |
120
- | ๐Ÿ”– `--tags` | Run tests with specified Cucumber tags | `artes --tags "@smoke or @wip"` |
121
- | ๐ŸŒ `--env` | Set the environment for the test run | `artes --env "dev"` |
122
- | `--saveVar` | Set the variables from CLI | `artes --saveVar '{"armud":20,"banana":200}'` |
123
- | ๐Ÿ•ถ๏ธ `--headless` | Run browser in headless mode | `artes --headless` |
124
- | โšก `--parallel` | Run tests in parallel mode | `artes --parallel 2` |
125
- | ๐Ÿ” `--retry` | Retry failed tests | `artes --retry 3` |
126
- | ๐Ÿ” `--rerun` | Rerun only the failed tests from previous run | `artes --rerun @rerun.txt` |
127
- | ๐ŸŽญ `--dryRun` | Perform a dry run without executing tests | `artes --dryRun` |
128
- | ๐Ÿ“ˆ `--percentage` | Set minimum success percentage to pass test run (default is 0) | `artes --percentage 85` |
129
- | ๐ŸŒ `--browser` | Specify browser to use (`chromium`, `firefox`, or `webkit`) | `artes --browser chromium` |
130
- | `--offline` | Run browser in offline mode | `artes --offline` |
131
- | ๐Ÿ“ฑ `--device` | Emulate specific device (e.g., "iPhone 13") | `artes --device "iPhone 13"` |
132
- | ๐Ÿ”— `--baseURL` | Set base URL for the tests | `artes --baseURL "https://example.com"` |
133
- | ๐Ÿ–ฅ๏ธ `--maxScreen` | Maximize browser window on launch | `artes --maxScreen` |
134
- | ๐Ÿ“ `--width` | Set browser width (default is 1280) | `artes --width 1920` |
135
- | ๐Ÿ“ `--height` | Set browser height (default is 720) | `artes --height 1080` |
136
- | โฑ๏ธ `--timeout` | Set timeout for each test step in seconds (default is 30 seconds) | `artes --timeout 10` |
137
- | ๐Ÿข `--slowMo` | Slow down text execution for clear view (default: 0 seconds) | `artes --slowMo 1` |
138
-
139
- \*\* To just run the tests: <br>
140
- Globally: artes <br>
141
- Locally: npx artes
142
-
143
- ---
144
-
145
- ## ๐ŸŽฏ Best Practices
146
-
147
- - **Global Installation:**
148
- For ease of use, it's recommended that Artes be installed globally. You can do this by running the following command:
149
-
150
- ```bash
151
- npm install -g artes
152
- ```
153
-
154
- - **Project Creation (Recommended):**
155
- To create a new project with Artes, use the `-c` flag. This will automatically set up the folder structure and configuration for you. Run the command:
156
-
157
- ```bash
158
- artes -c
159
- ```
160
-
161
- ๐Ÿ—‚๏ธ Example Project Structure: <br/>
162
- After running the `-c` flag to create a new project, the structure will look like this:
163
-
164
- ```
165
- /artes (Project Name)
166
- /tests
167
- /features
168
- (Your feature files here)
169
- /POMs // Optional
170
- (POM JSON file here)
171
- /steps // For custom steps
172
- (Your step definition JS files here)
173
- artes.config.js
174
- /report
175
- (Generated Allure report HTML here)
176
- ```
177
-
178
- **If you choose not to use the `-c` flag**, you can still download Artes to your testing project and use the prepared steps by running:
179
-
180
- ```bash
181
- npx artes
182
- ```
183
-
184
- You must customize the paths of features, steps, and other configurations by editing the `artes.config.js` file located inside your project folder (or create it).
185
-
186
- For example:
187
-
188
- ```javascript
189
- module.exports = {
190
- paths: ["tests/features/"], // Custom path for feature files
191
- require: ["tests/steps/*.js"], // Custom path for step definitions files
192
- pomPath: "tests/POMS/*.js", // Custom path for POM files
193
- };
194
- ```
195
-
196
- ---
197
-
198
- ## ๐Ÿ“ Writing Feature Files and POM Files
199
-
200
- Artes simplifies your test writing with structured feature files and organized Page Object Models (POM). Hereโ€™s how you can create them:
201
-
202
- ### 1. ๐Ÿ“„ Feature File Structure
203
-
204
- ```gherkin
205
- Feature: Searching on Google ๐Ÿ”
206
- Scenario Outline: Search for a term on Google
207
- Given User is on "https://www.google.com/" page
208
- When User types "alma" in "google_search_input"
209
- And User clicks "google_search_button"
210
- And User waits 10 seconds
211
- Then "google_text" should have "Alma" text
212
- ```
213
-
214
- - **Feature**: Describes the main feature being tested (e.g., Google search).
215
- - **Scenario Outline**: Defines a test case with steps.
216
- - **Steps**: Use `Given`, `When`, `And`, `Then` keywords to describe actions and expectations.
217
- - **Selectors**: The element names (e.g., `google_search_input`, `google_search_button`) map to the POM file or can be defined directly.
218
-
219
- ### 2. ๐Ÿ“‚ POM File Example
220
-
221
- ```json
222
- {
223
- "google_search_input": { "selector": "#APjFqb" },
224
- "google_search_button": {
225
- "selector": "input.gNO89b"
226
- },
227
- "google_text": {
228
- "selector": "#rso div h3",
229
- "waitTime": 5 //seconds
230
- }
231
- }
232
- ```
233
-
234
- - ๐Ÿ“‘ Using POM File is optional but it is **RECOMMENDED**
235
- - ๐Ÿ”— Using Selector in Feature File is possible
236
- ```gherkin
237
- When User types "alma" in "#APjFqb"
238
- ```
239
- - ๐Ÿ It is good to use snake_case for element names
240
- - โณ "waitTime" is to define custom wait for elements, but the feature currently under development.
241
- "selector" must be used if "waitTime" is used, but when using only selector is not needed mention in "selector"
242
-
243
- ---
244
-
245
- ## ๐Ÿ”„ Variable Management
246
-
247
- Artes provides powerful variable management capabilities that allow you to save, reuse, and share variables across test steps.
248
-
249
- ### Saving Variables from API Responses
250
-
251
- You can save variables directly from API responses, even using dot notation to extract nested values:
252
-
253
- ```gherkin
254
- When User sends GET request to "https://www.test.com" and saves "id" variables
255
- And User sends GET request to "https://www.test.com/items/{{id}}"
256
- Then User expects that response should have 200 status code
257
- ```
258
-
259
- ### Manual Variable Assignment
260
-
261
- Save variables manually using the dedicated step:
262
-
263
- ```gherkin
264
- And User saves "15" variable as "id"
265
- ```
266
-
267
- ### Variable Randomization
268
-
269
- Artes includes built-in randomization for generating dynamic test data:
270
-
271
- ```gherkin
272
- And User sets random email as "email"
273
- And User sets random 5 words as "description"
274
- And User sets random fullname as "fullName"
275
- ```
276
-
277
- ### Using Variables in Tests
278
-
279
- Reference saved variables anywhere in your tests using double curly braces:
280
-
281
- ```gherkin
282
- When User types "{{email}}" in "email_input"
283
- ```
284
-
285
- ๐Ÿ“š **For detailed information and complete step definitions**, visit the [Variable Management Documentation](https://github.com/4gayev1/Artes/blob/main/docs/stepDefinitions.md#variable-management).
286
-
287
- ---
288
-
289
- ## ๐Ÿ› ๏ธ Customization
290
-
291
- ## โœ๏ธ Writing Custom Step Definitions
292
-
293
- Artes allows you to extend its functionality by writing custom step definitions. Here's how you can do it:
294
-
295
- ### Import Required APIs
296
-
297
- ```javascript
298
- const {
299
- expect,
300
- Given,
301
- When,
302
- Then,
303
- element,
304
- context,
305
- keyboard,
306
- mouse,
307
- frame,
308
- assert,
309
- elementInteractions,
310
- } = require("artes"); // Common JS
311
- import { expect, Given, When, Then, element, context } from "artes"; // ES Modules (Do not RECOMMENDED)
312
- ```
313
-
314
- - **`Given`, `When`, `Then`**: These define your steps in Cucumber syntax. Example:
315
-
316
- ```javascript
317
- Given("User is on the login page", async () => {
318
- await context.page.navigateTo("https://example.com/login");
319
- });
320
- ```
321
-
322
- - **`page`**: Provides higher-level page actions such as navigation and waiting(Same as PlayWright). Examples:
323
- - Navigate to a URL:
324
- ```javascript
325
- await context.page.navigate("https://example.com");
326
- ```
327
- - Wait for a selector:
328
- ```javascript
329
- await context.page.waitForSelector("#loadingSpinner");
330
- ```
331
- - **`request`**: Use for sending HTTP requests. _(Note: This feature is currently under development.)_
332
-
333
- - **`element`**: Use for interacting with elements on the web page. Examples:
334
- - Clicking a button:
335
- ```javascript
336
- await element("#submitButton").click();
337
- ```
338
- - Filling an input:
339
- ```javascript
340
- await element("#username").fill("testUser");
341
- ```
342
- - **`expect`**: Use for assertions in your steps. For example:
343
- ```javascript
344
- expect(actualValue).toBe(expectedValue);
345
- expect(element("Page_Title")).toHaveText(expectedValue);
346
- ```
347
-
348
- ## ๐Ÿ“‹ Simplified Functions
349
-
350
- If you don't want to deal with Playwright methods directly, you can simply use the following predefined actions methods by import them:
351
-
352
- ```javascript
353
- const { mouse, keyboard, frame, elementInteractions, page } = require("artes");
354
- ```
355
-
356
- - **Mouse Actions:**
357
- `mouse.click(element)`
358
-
359
- - **Keyboard Actions:**
360
- `keyboard.press(key)`
361
-
362
- - **Element Interactions:**
363
- `elementInteractions.isChecked()`
364
-
365
- - **Assertions:**
366
- `assert.shouldBeTruthy(element)`
367
-
368
- - **Frame Actions:**
369
- `frame.first()`
370
-
371
- - **API Actions:**
372
- `api.post(url, payload, requestDataType)`
373
-
374
- ---
375
-
376
- For a detailed explanation of each function, please refer to the [function definitions](./docs/functionDefinitions.md).
377
-
378
- ---
379
-
380
- ### Example of Custom Step Definition
381
-
382
- ```javascript
383
- const { Given, When, Then, expect, element, page } = require("artes");
384
-
385
- Given("User is on the home page", async () => {
386
- await page.navigate("https://example.com");
387
- });
388
-
389
- When("User clicks the login button", async () => {
390
- await element("#loginButton").click();
391
- });
392
-
393
- Then("User should see the login form", async () => {
394
- expect(element("#loginForm")).toBeVisible(true);
395
- });
396
- ```
397
-
398
- ## ๐Ÿช Hooks (Lifecycle Hooks)
399
-
400
- Artes supports **hooks** that allow you to execute custom logic **before and after tests, scenarios, and steps**.
401
-
402
- Hooks are **user-defined**.
403
-
404
- ---
405
-
406
- ### ๐Ÿ“ Hooks File Location
407
-
408
- Create the following file **inside your project** (optional):
409
-
410
- ```
411
- tests/steps/hooks.js
412
- ```
413
-
414
- ---
415
-
416
- ### โœ๏ธ Writing Hooks
417
-
418
- You can define **only the hooks you need** in hooks.js under the steps folder.
419
- Undefined hooks are automatically skipped.
420
-
421
- ```js
422
- // tests/steps/hooks.js
423
-
424
- export function BeforeStep() {
425
- // hook for before each step
426
- }
427
-
428
- export function Before() {
429
- // hook for before each test
430
- }
431
-
432
- export function BeforeAll() {
433
- // hook for before all tests
434
- }
435
-
436
- export function AfterStep() {
437
- // hook for after each step
438
- }
439
-
440
- export function After() {
441
- // hook for after each test
442
- }
443
-
444
- export function AfterAll() {
445
- // hook for after all tests
446
- }
447
- ```
448
-
449
- ---
450
-
451
- ### ๐Ÿ” Supported Hook Types
452
-
453
- | Hook Name | Execution Time |
454
- | ------------ | ----------------------------- |
455
- | `BeforeAll` | Once before **all scenarios** |
456
- | `Before` | Before **each scenario** |
457
- | `BeforeStep` | Before **each step** |
458
- | `AfterStep` | After **each step** |
459
- | `After` | After **each scenario** |
460
- | `AfterAll` | Once after **all scenarios** |
461
-
462
- ---
463
-
464
- ### โ–ถ๏ธ Execution Order Example
465
-
466
- For a scenario with steps:
467
-
468
- ```
469
- BeforeAll
470
- Before
471
- BeforeStep
472
- (step executes)
473
- AfterStep
474
- After
475
- AfterAll
476
- ```
477
-
478
- ---
479
-
480
- ## โš™๏ธ Configuration
481
-
482
- You can configure Artes by editing the `artes.config.js` file. Below are the default configuration options with explanations:
483
-
484
- | **Option** | **Default Value** | **Description** |
485
- | ----------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------- |
486
- | `headless` | `false` | Run browser in headless mode. |
487
- | `env` | `""` | Environment name for tests. |
488
- | `variables` | `{}` | Variables for tests. |
489
- | `baseURL` | `""` | Base URL for API or web tests. |
490
- | `timeout` | `30` | Default timeout in seconds. |
491
- | `slowMo` | `0` | Default slow motion in seconds. |
492
- | `paths` | `[moduleConfig.featuresPath]` | Paths to feature files. |
493
- | `require` | `[moduleConfig.stepsPath, "src/stepDefinitions/*.js", "src/hooks/hooks.js"]` | Support code paths (CommonJS). |
494
- | `pomPath` | `moduleConfig.pomPath` | Path to Page Object Models. |
495
- | `import` | `[]` | Support code paths. |
496
- | `testPercentage` | `0` | Define test coverage percentage |
497
- | `report` | `false` | Generate report |
498
- | `zip` | `false` | Generate zip of report |
499
- | `reportSuccess` | `false` | Add screenshots and video records also for success test cases |
500
- | `trace` | `false` | Enable tracing |
501
- | `reportWithTrace` | `false` | Include trace in report |
502
- | `format` | `["rerun:@rerun.txt", "allure-cucumberjs/reporter"]` | Formatter names/paths. |
503
- | `formatOptions` | `{ "resultsDir": "allure-result" }` | Formatter options. |
504
- | `parallel` | `1` | Number of parallel workers. |
505
- | `browser` | `"chrome"` | Browser to use: "chrome", "firefox", "webkit". |
506
- | `offline` | `false` | Run browser in offline mode. |
507
- | `device` | `""` | Emulate specific device (e.g., "iPhone 13"). |
508
- | `width` | `1280` | Browser width in pixels. |
509
- | `height` | `720` | Browser height in pixels. |
510
- | `maximizeScreen` | `true` | Maximize browser window on start. |
511
- | `dryRun` | `false` | Prepare test run without execution. |
512
- | `failFast` | `false` | Stop on first test failure. |
513
- | `forceExit` | `false` | Force `process.exit()` after tests |
514
- | `strict` | `true` | Fail on pending steps. |
515
- | `backtrace` | `false` | Show full backtrace for errors. |
516
- | `tags` | `""` | Tag expression to filter scenarios. |
517
- | `name` | `[]` | Run scenarios matching regex. |
518
- | `order` | `"defined"` | Run order (defined/random). |
519
- | `language` | `"en"` | Default feature file language. |
520
- | `loader` | `[]` | Module loader specifications. |
521
- | `requireModule` | `[]` | Transpilation module names. |
522
- | `retry` | `0` | Retry attempts for failing tests. |
523
- | `retryTagFilter` | `""` | Tag expression for retries. |
524
- | `publish` | `false` | Publish to cucumber.io. |
525
- | `worldParameters` | `{}` | Custom world parameters. |
526
-
527
- ---
528
-
529
- ## ๐ŸŒ Environment Configuration
530
-
531
- | **Option** | **Default Value** | **Description** |
532
- | ---------- | ----------------- | ------------------------------------------------------------------------------------------------------------ |
533
- | `env` | `""` | Environment configuration. Should match the name with the baseURL object, like "dev" |
534
- | `baseURL` | `""` | Base URL for API requests. Can be object {"dev":"dev-api.com", "pre":"pre-api.com"}, or string "dev-api.com" |
535
-
536
- ### Environment Variables Configuration
537
-
538
- Artes supports environment-specific configurations through environment variables. This feature allows to manage different settings for environments.
539
-
540
- ### Setting Up Environment Variables
541
-
542
- 1. **Configure Environment in artes.config.js:**
543
-
544
- ```javascript
545
- module.exports = {
546
- baseURL: {
547
- dev: "https://dev.alma.az",
548
- pre: "https://pre.alma.az",
549
- prod: "https://api.alma.az",
550
- },
551
- env: "dev", // Specify which environment to use
552
- };
553
- ```
554
-
555
- **Alternative single URL configuration:**
556
-
557
- ```javascript
558
- module.exports = {
559
- baseURL: "https://api.alma.az", // Direct string URL
560
- };
561
- ```
562
-
563
- 2. **Create Environment Variable Files:**
564
- Create JSON files under `src/tests/environment_variables/` folder with names matching your environment:
565
-
566
- **dev.env.json:**
567
-
568
- ```json
569
- {
570
- "api_key": "dev-api-key-12345",
571
- "auth_token": "dev-auth-token",
572
- "database_url": "dev-db.example.com",
573
- "timeout": 5000,
574
- "headers": {
575
- "Authorization": "Bearer dev-token",
576
- "Content-Type": "application/json"
577
- }
578
- }
579
- ```
580
-
581
- ### How It Works
582
-
583
- 1. **Environment Detection:** When Artes runs, it reads the `env` value from `artes.config.js`
584
- 2. **Base URL Resolution:** If `baseURL` is an object, it uses the environment key to find the corresponding URL. If `baseURL` is a string, it uses it directly
585
- 3. **Variable Loading:** Artes looks for a JSON file matching the environment name in `src/tests/environment_variables/`
586
- 4. **Runtime Access:** All variables from the environment file become available during test execution
587
-
588
- ### Important Notes
589
-
590
- - โš ๏ธ **Base URLs must be defined in `artes.config.js`** - they cannot be set in the environment variable JSON files
591
- - ๐Ÿ“ Environment variable files should be placed in `src/tests/environment_variables/`
592
- - ๐Ÿท๏ธ File names must follow the format `{env}.env.json` (e.g., `dev.env.json` for `env: "dev"`)
593
- - ๐Ÿ”„ Variables are loaded into variable storage and can be accessed during test runs
594
- - ๐ŸŒ Use environment variables for headers, API keys, timeouts, and other environment-specific configurations
595
-
596
- ---
597
-
598
- ### Browser Configuration
599
-
600
- | Option | Default Value | Description |
601
- | ------------- | ------------------------------ | ------------------------------------------------------ |
602
- | `browserType` | `"chrome"` | Browser type (`"chrome"`, `"firefox"`, or `"webkit"`). |
603
- | `viewport` | `{ width: 1280, height: 720 }` | Browser viewport size. |
604
- | `headless` | `true` | Run browser in headless mode (`true` or `false`). |
605
- | `offline` | `false` | Run browser in offline mode (`true` or `false`). |
606
-
607
-
608
- ### Device Configuration
609
-
610
- | Option | Default Value | Description |
611
- | ------------- | ------------------------------ | ------------------------------------------------------ |
612
- | `device` | `""` | [Device List](./docs/emulationDevicesList.md) |
613
-
614
-
615
- ## ๐Ÿ“Š Report Generation
616
-
617
- Artes can generate Allure reports. After running tests with the `-r` flag, the reports will be stored in the `report` folder in HTML format. You can view them in your browser after the tests complete.
618
-
619
- ---
620
-
621
- ## ๐Ÿณ Docker Image for CI/CD
622
-
623
- A Docker image `vahidaghayev/artes` is available for running Artes in CI/CD pipelines. This image includes:
624
-
625
- - **Playwright Browsers**: Pre-installed to support UI testing.
626
- - **Xvfb**: Enables running UI tests with video recording in a virtual display.
627
-
628
- ### Recommended Settings for Best Quality
629
-
630
- To achieve the best video recording quality, use the following command:
631
-
632
- ```bash
633
- xvfb-run -a --server-args="-screen 0 3840x1180x24" --auto-servernum npx artes --width 1600 --height 900
634
- ```
635
-
636
- ---
637
-
638
- ## ๐Ÿ‘ Good To Use
639
-
640
- If you don't use the -c or --create option that the package offers, save the file below under the `.vscode` folder:
641
-
642
- - Those configurations will help autocomplete both predefined and custom step definitions in your features file
643
-
644
- **extensions.json**
645
-
646
- ```json
647
- {
648
- "recommendations": ["CucumberOpen.cucumber-official"]
649
- }
650
- ```
651
-
652
- **settings.json**
653
-
654
- ```json
655
- {
656
- "cucumber.glue": [
657
- "tests/steps/*.{ts,js}",
658
- "node_modules/artes/src/tests/stepDefinitions/*.{ts,js}"
659
- ],
660
- "cucumber.features": ["tests/features/*.features"],
661
- "cucumberautocomplete.syncfeatures": true,
662
- "cucumberautocomplete.strictGherkinCompletion": true
663
- }
664
- ```
665
-
666
- ---
667
-
668
- ## ๐Ÿง‘โ€๐Ÿ’ป Have a Good Testing
1
+ <p align="center">
2
+ <img alt="artesLogo" src="https://github.com/user-attachments/assets/e0641011-0e96-4330-8ad5-935b395b0838" width="280">
3
+ </p>
4
+
5
+ <h1 align="center">Artes</h1>
6
+
7
+ ## ๐Ÿš€ Summary
8
+
9
+ Artes is a test runner for Playwright that executes [predefined Cucumber tests](./docs/stepDefinitions.md) and can generate Allure reports for test results. It simplifies setting up Playwright with Cucumber in your automation workflow. With Artes, you can easily run tests without writing step definitions, generate reports, and customize your testing environment.
10
+
11
+ ![artes demonstration](https://github.com/user-attachments/assets/c46172f7-103d-45d1-a37d-8d4267df0967)
12
+
13
+ ---
14
+
15
+ ## ๐ŸŒŸ Artes Benefits
16
+
17
+ ### ๐Ÿš€ Fast Setup & Smooth Onboarding
18
+
19
+ - Install in minutes and create a test project effortlessly
20
+ - Well-structured, easy-to-follow documentation for a smooth learning curve
21
+ - Designed for long-term maintainability and scalability
22
+
23
+ ### ๐Ÿงฉ Powerful & Developer-Friendly Architecture
24
+
25
+ - Intuitive API for writing custom step definitions
26
+ - Rich set of ready-to-use step definitions to speed up test creation
27
+ - Fully extensible โ€” add your own step definitions anytime
28
+
29
+ ### ๐ŸŒ Advanced API Testing
30
+
31
+ - Schema validation to ensure API response correctness
32
+ - Rich assertion library for precise validations
33
+ - Support for all HTTP methods
34
+ - Environment-based API configuration for flexible testing
35
+
36
+ ### ๐Ÿ” Smart Variable & Data Handling
37
+
38
+ - Page Object Model (POM) support for structured data management
39
+ - Save, reuse, and share variables across steps
40
+ - Built-in data randomization for dynamic and realistic test data
41
+ - Environment-specific variables for clean environment separation
42
+
43
+ ### ๐Ÿ–ฅ๏ธ Modern UI Automation
44
+
45
+ - Wide locator strategy support (CSS, XPath, text-based, and more)
46
+ - Built-in browser actions
47
+ - Cookie management
48
+ - Local & session storage handling
49
+
50
+ ### โš™๏ธ Flexible Configuration & Hooks
51
+
52
+ - Environment-based configuration system
53
+ - Powerful and customizable configuration files
54
+ - Full hook support:
55
+ - Before / After
56
+ - Step-level and scenario-level hooks
57
+
58
+ ### ๐Ÿงช CLI, CI/CD & Containerization
59
+
60
+ - Powerful CLI for full control from the command line
61
+ - Official [Artes Docker image](https://hub.docker.com/r/vahidaghayev/artes) for seamless containerized execution
62
+ - CI/CD-ready โ€” integrate easily with any pipeline
63
+
64
+ ### ๐Ÿ“Š Artes Reporting System
65
+
66
+ - Easy installation with docker compose (For detailed info: [Artes Reporting System](https://github.com/4gayev1/artes-reporting-system))
67
+ - Multiple reporting formats supported
68
+ - Native Allure reporting integration
69
+ - Customizable Artes Reporting System
70
+
71
+ ---
72
+
73
+ ## ๐Ÿง‘โ€๐Ÿ’ป Installation
74
+
75
+ You can install **Artes** via npm. To install it globally **(RECOMMENDED)**, run the following command:
76
+
77
+ ```bash
78
+ npm install -g artes
79
+ ```
80
+
81
+ To install it locally in your project, run:
82
+
83
+ ```bash
84
+ npm install artes
85
+ ```
86
+
87
+ Once installed, you can run **Artes** using:
88
+
89
+ ```bash
90
+ npx artes [options]
91
+ ```
92
+
93
+ ---
94
+
95
+ ## ๐Ÿ’ก Usage
96
+
97
+ **Artes** has following CLI options:
98
+
99
+ ```bash
100
+ npx artes [options]
101
+ ```
102
+
103
+ ### Options
104
+
105
+ | Option | Description | Usage Example |
106
+ | ------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
107
+ | ๐Ÿ†˜ `-h, --help` | Show the usage options | `artes -h` or `artes --help` |
108
+ | ๐Ÿท๏ธ `-v, --version` | Show the current version of Artes | `artes -v` or `artes --version` |
109
+ | ๐Ÿ—๏ธ `-c, --create` | Create an example project with Artes | `artes -c` or `artes --create` |
110
+ | โœ… `-y, --yes` | Skip the confirmation prompt when creating an example project | `artes -c -y` or `artes --create --yes` |
111
+ | ๐Ÿšซ --noDeps | Skip installing dependencies when creating example project | `artes -c --noDeps` |
112
+ | ๐Ÿ“Š `-r, --report` | Run tests and generate Allure report | `artes -r` or `artes --report` |
113
+ | `--reportSuccess` | Add screenshots and video records for also Success test cases | `artes --reportSuccess` |
114
+ | `--trace` | Enable tracing | `artes --trace` |
115
+ | `-rwt, --reportWithTrace` | Add trace to the report | `artes -rwt` or `artes --reportWithTrace` |
116
+ | `--singleFileReport` | Generate single file allure report | `artes -r --singleFileReport` |
117
+ | `--zip` | Zip the report folder after generation | `artes -r --zip` |
118
+ | ๐Ÿ“ `--features` | Specify one or more feature files' relative paths to run (comma-separated) | `artes --features "tests/features/Alma,tests/features/Banan.feature"` |
119
+ | ๐Ÿ“œ `--stepDef` | Specify one or more step definition files' relative paths to use (comma-separated) | `artes --stepDef "tests/steps/login.js,tests/steps/home.js"` |
120
+ | ๐Ÿ”– `--tags` | Run tests with specified Cucumber tags | `artes --tags "@smoke or @wip"` |
121
+ | ๐ŸŒ `--env` | Set the environment for the test run | `artes --env "dev"` |
122
+ | `--saveVar` | Set the variables from CLI | `artes --saveVar '{"armud":20,"banana":200}'` |
123
+ | ๐Ÿ•ถ๏ธ `--headless` | Run browser in headless mode | `artes --headless` |
124
+ | โšก `--parallel` | Run tests in parallel mode | `artes --parallel 2` |
125
+ | ๐Ÿ” `--retry` | Retry failed tests | `artes --retry 3` |
126
+ | ๐Ÿ” `--rerun` | Rerun only the failed tests from previous run | `artes --rerun @rerun.txt` |
127
+ | ๐ŸŽญ `--dryRun` | Perform a dry run without executing tests | `artes --dryRun` |
128
+ | ๐Ÿ“ˆ `--percentage` | Set minimum success percentage to pass test run (default is 0) | `artes --percentage 85` |
129
+ | ๐ŸŒ `--browser` | Specify browser to use (`chromium`, `firefox`, or `webkit`) | `artes --browser chromium` |
130
+ | `--offline` | Run browser in offline mode | `artes --offline` |
131
+ | ๐Ÿ“ฑ `--device` | Emulate specific device (e.g., "iPhone 13") | `artes --device "iPhone 13"` |
132
+ | ๐Ÿ”— `--baseURL` | Set base URL for the tests | `artes --baseURL "https://example.com"` |
133
+ | ๐Ÿ–ฅ๏ธ `--maxScreen` | Maximize browser window on launch | `artes --maxScreen` |
134
+ | ๐Ÿ“ `--width` | Set browser width (default is 1280) | `artes --width 1920` |
135
+ | ๐Ÿ“ `--height` | Set browser height (default is 720) | `artes --height 1080` |
136
+ | โฑ๏ธ `--timeout` | Set timeout for each test step in seconds (default is 30 seconds) | `artes --timeout 10` |
137
+ | ๐Ÿข `--slowMo` | Slow down text execution for clear view (default: 0 seconds) | `artes --slowMo 1` |
138
+
139
+ \*\* To just run the tests: <br>
140
+ Globally: artes <br>
141
+ Locally: npx artes
142
+
143
+ ---
144
+
145
+ ## ๐ŸŽฏ Best Practices
146
+
147
+ - **Global Installation:**
148
+ For ease of use, it's recommended that Artes be installed globally. You can do this by running the following command:
149
+
150
+ ```bash
151
+ npm install -g artes
152
+ ```
153
+
154
+ - **Project Creation (Recommended):**
155
+ To create a new project with Artes, use the `-c` flag. This will automatically set up the folder structure and configuration for you. Run the command:
156
+
157
+ ```bash
158
+ artes -c
159
+ ```
160
+
161
+ ๐Ÿ—‚๏ธ Example Project Structure: <br/>
162
+ After running the `-c` flag to create a new project, the structure will look like this:
163
+
164
+ ```
165
+ /artes (Project Name)
166
+ /tests
167
+ /features
168
+ (Your feature files here)
169
+ /POMs // Optional
170
+ (POM JSON file here)
171
+ /steps // For custom steps
172
+ (Your step definition JS files here)
173
+ artes.config.js
174
+ /report
175
+ (Generated Allure report HTML here)
176
+ ```
177
+
178
+ **If you choose not to use the `-c` flag**, you can still download Artes to your testing project and use the prepared steps by running:
179
+
180
+ ```bash
181
+ npx artes
182
+ ```
183
+
184
+ You must customize the paths of features, steps, and other configurations by editing the `artes.config.js` file located inside your project folder (or create it).
185
+
186
+ For example:
187
+
188
+ ```javascript
189
+ module.exports = {
190
+ paths: ["tests/features/"], // Custom path for feature files
191
+ require: ["tests/steps/*.js"], // Custom path for step definitions files
192
+ pomPath: "tests/POMS/*.js", // Custom path for POM files
193
+ };
194
+ ```
195
+
196
+ ---
197
+
198
+ ## ๐Ÿ“ Writing Feature Files and POM Files
199
+
200
+ Artes simplifies your test writing with structured feature files and organized Page Object Models (POM). Hereโ€™s how you can create them:
201
+
202
+ ### 1. ๐Ÿ“„ Feature File Structure
203
+
204
+ ```gherkin
205
+ Feature: Searching on Google ๐Ÿ”
206
+ Scenario Outline: Search for a term on Google
207
+ Given User is on "https://www.google.com/" page
208
+ When User types "alma" in "google_search_input"
209
+ And User clicks "google_search_button"
210
+ And User waits 10 seconds
211
+ Then "google_text" should have "Alma" text
212
+ ```
213
+
214
+ - **Feature**: Describes the main feature being tested (e.g., Google search).
215
+ - **Scenario Outline**: Defines a test case with steps.
216
+ - **Steps**: Use `Given`, `When`, `And`, `Then` keywords to describe actions and expectations.
217
+ - **Selectors**: The element names (e.g., `google_search_input`, `google_search_button`) map to the POM file or can be defined directly.
218
+
219
+ ### 2. ๐Ÿ“‚ POM File Example
220
+
221
+ ```json
222
+ {
223
+ "google_search_input": { "selector": "#APjFqb" },
224
+ "google_search_button": {
225
+ "selector": "input.gNO89b"
226
+ },
227
+ "google_text": {
228
+ "selector": "#rso div h3",
229
+ "waitTime": 5 //seconds
230
+ }
231
+ }
232
+ ```
233
+
234
+ - ๐Ÿ“‘ Using POM File is optional but it is **RECOMMENDED**
235
+ - ๐Ÿ”— Using Selector in Feature File is possible
236
+ ```gherkin
237
+ When User types "alma" in "#APjFqb"
238
+ ```
239
+ - ๐Ÿ It is good to use snake_case for element names
240
+ - โณ "waitTime" is to define custom wait for elements, but the feature currently under development.
241
+ "selector" must be used if "waitTime" is used, but when using only selector is not needed mention in "selector"
242
+
243
+ ---
244
+
245
+ ## ๐Ÿ”„ Variable Management
246
+
247
+ Artes provides powerful variable management capabilities that allow you to save, reuse, and share variables across test steps.
248
+
249
+ ### Saving Variables from API Responses
250
+
251
+ You can save variables directly from API responses, even using dot notation to extract nested values:
252
+
253
+ ```gherkin
254
+ When User sends GET request to "https://www.test.com" and saves "id" variables
255
+ And User sends GET request to "https://www.test.com/items/{{id}}"
256
+ Then User expects that response should have 200 status code
257
+ ```
258
+
259
+ ### Manual Variable Assignment
260
+
261
+ Save variables manually using the dedicated step:
262
+
263
+ ```gherkin
264
+ And User saves "15" variable as "id"
265
+ ```
266
+
267
+ ### Variable Randomization
268
+
269
+ Artes includes built-in randomization for generating dynamic test data:
270
+
271
+ ```gherkin
272
+ And User sets random email as "email"
273
+ And User sets random 5 words as "description"
274
+ And User sets random fullname as "fullName"
275
+ ```
276
+
277
+ ### Using Variables in Tests
278
+
279
+ Reference saved variables anywhere in your tests using double curly braces:
280
+
281
+ ```gherkin
282
+ When User types "{{email}}" in "email_input"
283
+ ```
284
+
285
+ ๐Ÿ“š **For detailed information and complete step definitions**, visit the [Variable Management Documentation](https://github.com/4gayev1/Artes/blob/main/docs/stepDefinitions.md#variable-management).
286
+
287
+ ---
288
+
289
+ ## ๐Ÿ› ๏ธ Customization
290
+
291
+ ## โœ๏ธ Writing Custom Step Definitions
292
+
293
+ Artes allows you to extend its functionality by writing custom step definitions. Here's how you can do it:
294
+
295
+ ### Import Required APIs
296
+
297
+ ```javascript
298
+ const {
299
+ expect,
300
+ Given,
301
+ When,
302
+ Then,
303
+ element,
304
+ context,
305
+ keyboard,
306
+ mouse,
307
+ frame,
308
+ assert,
309
+ elementInteractions,
310
+ } = require("artes"); // Common JS
311
+ import { expect, Given, When, Then, element, context } from "artes"; // ES Modules (Do not RECOMMENDED)
312
+ ```
313
+
314
+ - **`Given`, `When`, `Then`**: These define your steps in Cucumber syntax. Example:
315
+
316
+ ```javascript
317
+ Given("User is on the login page", async () => {
318
+ await context.page.navigateTo("https://example.com/login");
319
+ });
320
+ ```
321
+
322
+ - **`page`**: Provides higher-level page actions such as navigation and waiting(Same as PlayWright). Examples:
323
+ - Navigate to a URL:
324
+ ```javascript
325
+ await context.page.navigate("https://example.com");
326
+ ```
327
+ - Wait for a selector:
328
+ ```javascript
329
+ await context.page.waitForSelector("#loadingSpinner");
330
+ ```
331
+ - **`request`**: Use for sending HTTP requests. _(Note: This feature is currently under development.)_
332
+
333
+ - **`element`**: Use for interacting with elements on the web page. Examples:
334
+ - Clicking a button:
335
+ ```javascript
336
+ await element("#submitButton").click();
337
+ ```
338
+ - Filling an input:
339
+ ```javascript
340
+ await element("#username").fill("testUser");
341
+ ```
342
+ - **`expect`**: Use for assertions in your steps. For example:
343
+ ```javascript
344
+ expect(actualValue).toBe(expectedValue);
345
+ expect(element("Page_Title")).toHaveText(expectedValue);
346
+ ```
347
+
348
+ ## ๐Ÿ“‹ Simplified Functions
349
+
350
+ If you don't want to deal with Playwright methods directly, you can simply use the following predefined actions methods by import them:
351
+
352
+ ```javascript
353
+ const { mouse, keyboard, frame, elementInteractions, page } = require("artes");
354
+ ```
355
+
356
+ - **Mouse Actions:**
357
+ `mouse.click(element)`
358
+
359
+ - **Keyboard Actions:**
360
+ `keyboard.press(key)`
361
+
362
+ - **Element Interactions:**
363
+ `elementInteractions.isChecked()`
364
+
365
+ - **Assertions:**
366
+ `assert.shouldBeTruthy(element)`
367
+
368
+ - **Frame Actions:**
369
+ `frame.first()`
370
+
371
+ - **API Actions:**
372
+ `api.post(url, payload, requestDataType)`
373
+
374
+ ---
375
+
376
+ For a detailed explanation of each function, please refer to the [function definitions](./docs/functionDefinitions.md).
377
+
378
+ ---
379
+
380
+ ### Example of Custom Step Definition
381
+
382
+ ```javascript
383
+ const { Given, When, Then, expect, element, page } = require("artes");
384
+
385
+ Given("User is on the home page", async () => {
386
+ await page.navigate("https://example.com");
387
+ });
388
+
389
+ When("User clicks the login button", async () => {
390
+ await element("#loginButton").click();
391
+ });
392
+
393
+ Then("User should see the login form", async () => {
394
+ expect(element("#loginForm")).toBeVisible(true);
395
+ });
396
+ ```
397
+
398
+ ## ๐Ÿช Hooks (Lifecycle Hooks)
399
+
400
+ Artes supports **hooks** that allow you to execute custom logic **before and after tests, scenarios, and steps**.
401
+
402
+ Hooks are **user-defined**.
403
+
404
+ ---
405
+
406
+ ### ๐Ÿ“ Hooks File Location
407
+
408
+ Create the following file **inside your project** (optional):
409
+
410
+ ```
411
+ tests/steps/hooks.js
412
+ ```
413
+
414
+ ---
415
+
416
+ ### โœ๏ธ Writing Hooks
417
+
418
+ You can define **only the hooks you need** in hooks.js under the steps folder.
419
+ Undefined hooks are automatically skipped.
420
+
421
+ ```js
422
+ // tests/steps/hooks.js
423
+
424
+ export function BeforeStep() {
425
+ // hook for before each step
426
+ }
427
+
428
+ export function Before() {
429
+ // hook for before each test
430
+ }
431
+
432
+ export function BeforeAll() {
433
+ // hook for before all tests
434
+ }
435
+
436
+ export function AfterStep() {
437
+ // hook for after each step
438
+ }
439
+
440
+ export function After() {
441
+ // hook for after each test
442
+ }
443
+
444
+ export function AfterAll() {
445
+ // hook for after all tests
446
+ }
447
+ ```
448
+
449
+ ---
450
+
451
+ ### ๐Ÿ” Supported Hook Types
452
+
453
+ | Hook Name | Execution Time |
454
+ | ------------ | ----------------------------- |
455
+ | `BeforeAll` | Once before **all scenarios** |
456
+ | `Before` | Before **each scenario** |
457
+ | `BeforeStep` | Before **each step** |
458
+ | `AfterStep` | After **each step** |
459
+ | `After` | After **each scenario** |
460
+ | `AfterAll` | Once after **all scenarios** |
461
+
462
+ ---
463
+
464
+ ### โ–ถ๏ธ Execution Order Example
465
+
466
+ For a scenario with steps:
467
+
468
+ ```
469
+ BeforeAll
470
+ Before
471
+ BeforeStep
472
+ (step executes)
473
+ AfterStep
474
+ After
475
+ AfterAll
476
+ ```
477
+
478
+ ---
479
+
480
+ ## โš™๏ธ Configuration
481
+
482
+ You can configure Artes by editing the `artes.config.js` file. Below are the default configuration options with explanations:
483
+
484
+ | **Option** | **Default Value** | **Description** |
485
+ | ----------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------- |
486
+ | `headless` | `false` | Run browser in headless mode. |
487
+ | `env` | `""` | Environment name for tests. |
488
+ | `variables` | `{}` | Variables for tests. |
489
+ | `baseURL` | `""` | Base URL for API or web tests. |
490
+ | `timeout` | `30` | Default timeout in seconds. |
491
+ | `slowMo` | `0` | Default slow motion in seconds. |
492
+ | `paths` | `[moduleConfig.featuresPath]` | Paths to feature files. |
493
+ | `require` | `[moduleConfig.stepsPath, "src/stepDefinitions/*.js", "src/hooks/hooks.js"]` | Support code paths (CommonJS). |
494
+ | `pomPath` | `moduleConfig.pomPath` | Path to Page Object Models. |
495
+ | `import` | `[]` | Support code paths. |
496
+ | `testPercentage` | `0` | Define test coverage percentage |
497
+ | `report` | `false` | Generate report |
498
+ | `zip` | `false` | Generate zip of report |
499
+ | `reportSuccess` | `false` | Add screenshots and video records also for success test cases |
500
+ | `trace` | `false` | Enable tracing |
501
+ | `reportWithTrace` | `false` | Include trace in report |
502
+ | `format` | `["rerun:@rerun.txt", "allure-cucumberjs/reporter"]` | Formatter names/paths. |
503
+ | `formatOptions` | `{ "resultsDir": "allure-result" }` | Formatter options. |
504
+ | `parallel` | `1` | Number of parallel workers. |
505
+ | `browser` | `"chrome"` | Browser to use: "chrome", "firefox", "webkit". |
506
+ | `offline` | `false` | Run browser in offline mode. |
507
+ | `device` | `""` | Emulate specific device (e.g., "iPhone 13"). |
508
+ | `width` | `1280` | Browser width in pixels. |
509
+ | `height` | `720` | Browser height in pixels. |
510
+ | `maximizeScreen` | `true` | Maximize browser window on start. |
511
+ | `dryRun` | `false` | Prepare test run without execution. |
512
+ | `failFast` | `false` | Stop on first test failure. |
513
+ | `forceExit` | `false` | Force `process.exit()` after tests |
514
+ | `strict` | `true` | Fail on pending steps. |
515
+ | `backtrace` | `false` | Show full backtrace for errors. |
516
+ | `tags` | `""` | Tag expression to filter scenarios. |
517
+ | `name` | `[]` | Run scenarios matching regex. |
518
+ | `order` | `"defined"` | Run order (defined/random). |
519
+ | `language` | `"en"` | Default feature file language. |
520
+ | `loader` | `[]` | Module loader specifications. |
521
+ | `requireModule` | `[]` | Transpilation module names. |
522
+ | `retry` | `0` | Retry attempts for failing tests. |
523
+ | `retryTagFilter` | `""` | Tag expression for retries. |
524
+ | `publish` | `false` | Publish to cucumber.io. |
525
+ | `worldParameters` | `{}` | Custom world parameters. |
526
+
527
+ ---
528
+
529
+ ## ๐ŸŒ Environment Configuration
530
+
531
+ | **Option** | **Default Value** | **Description** |
532
+ | ---------- | ----------------- | ------------------------------------------------------------------------------------------------------------ |
533
+ | `env` | `""` | Environment configuration. Should match the name with the baseURL object, like "dev" |
534
+ | `baseURL` | `""` | Base URL for API requests. Can be object {"dev":"dev-api.com", "pre":"pre-api.com"}, or string "dev-api.com" |
535
+
536
+ ### Environment Variables Configuration
537
+
538
+ Artes supports environment-specific configurations through environment variables. This feature allows to manage different settings for environments.
539
+
540
+ ### Setting Up Environment Variables
541
+
542
+ 1. **Configure Environment in artes.config.js:**
543
+
544
+ ```javascript
545
+ module.exports = {
546
+ baseURL: {
547
+ dev: "https://dev.alma.az",
548
+ pre: "https://pre.alma.az",
549
+ prod: "https://api.alma.az",
550
+ },
551
+ env: "dev", // Specify which environment to use
552
+ };
553
+ ```
554
+
555
+ **Alternative single URL configuration:**
556
+
557
+ ```javascript
558
+ module.exports = {
559
+ baseURL: "https://api.alma.az", // Direct string URL
560
+ };
561
+ ```
562
+
563
+ 2. **Create Environment Variable Files:**
564
+ Create JSON files under `src/tests/environment_variables/` folder with names matching your environment:
565
+
566
+ **dev.env.json:**
567
+
568
+ ```json
569
+ {
570
+ "api_key": "dev-api-key-12345",
571
+ "auth_token": "dev-auth-token",
572
+ "database_url": "dev-db.example.com",
573
+ "timeout": 5000,
574
+ "headers": {
575
+ "Authorization": "Bearer dev-token",
576
+ "Content-Type": "application/json"
577
+ }
578
+ }
579
+ ```
580
+
581
+ ### How It Works
582
+
583
+ 1. **Environment Detection:** When Artes runs, it reads the `env` value from `artes.config.js`
584
+ 2. **Base URL Resolution:** If `baseURL` is an object, it uses the environment key to find the corresponding URL. If `baseURL` is a string, it uses it directly
585
+ 3. **Variable Loading:** Artes looks for a JSON file matching the environment name in `src/tests/environment_variables/`
586
+ 4. **Runtime Access:** All variables from the environment file become available during test execution
587
+
588
+ ### Important Notes
589
+
590
+ - โš ๏ธ **Base URLs must be defined in `artes.config.js`** - they cannot be set in the environment variable JSON files
591
+ - ๐Ÿ“ Environment variable files should be placed in `src/tests/environment_variables/`
592
+ - ๐Ÿท๏ธ File names must follow the format `{env}.env.json` (e.g., `dev.env.json` for `env: "dev"`)
593
+ - ๐Ÿ”„ Variables are loaded into variable storage and can be accessed during test runs
594
+ - ๐ŸŒ Use environment variables for headers, API keys, timeouts, and other environment-specific configurations
595
+
596
+ ---
597
+
598
+ ### Browser Configuration
599
+
600
+ | Option | Default Value | Description |
601
+ | ------------- | ------------------------------ | ------------------------------------------------------ |
602
+ | `browserType` | `"chrome"` | Browser type (`"chrome"`, `"firefox"`, or `"webkit"`). |
603
+ | `viewport` | `{ width: 1280, height: 720 }` | Browser viewport size. |
604
+ | `headless` | `true` | Run browser in headless mode (`true` or `false`). |
605
+ | `offline` | `false` | Run browser in offline mode (`true` or `false`). |
606
+
607
+
608
+ ### Device Configuration
609
+
610
+ | Option | Default Value | Description |
611
+ | ------------- | ------------------------------ | ------------------------------------------------------ |
612
+ | `device` | `""` | [Device List](./docs/emulationDevicesList.md) |
613
+
614
+
615
+ ## ๐Ÿ“Š Report Generation
616
+
617
+ Artes can generate Allure reports. After running tests with the `-r` flag, the reports will be stored in the `report` folder in HTML format. You can view them in your browser after the tests complete.
618
+
619
+ ---
620
+
621
+ ## ๐Ÿณ Docker Image for CI/CD
622
+
623
+ A Docker image `vahidaghayev/artes` is available for running Artes in CI/CD pipelines. This image includes:
624
+
625
+ - **Playwright Browsers**: Pre-installed to support UI testing.
626
+ - **Xvfb**: Enables running UI tests with video recording in a virtual display.
627
+
628
+ ### Recommended Settings for Best Quality
629
+
630
+ To achieve the best video recording quality, use the following command:
631
+
632
+ ```bash
633
+ xvfb-run -a --server-args="-screen 0 3840x1180x24" --auto-servernum npx artes --width 1600 --height 900
634
+ ```
635
+
636
+ ---
637
+
638
+ ## ๐Ÿ‘ Good To Use
639
+
640
+ If you don't use the -c or --create option that the package offers, save the file below under the `.vscode` folder:
641
+
642
+ - Those configurations will help autocomplete both predefined and custom step definitions in your features file
643
+
644
+ **extensions.json**
645
+
646
+ ```json
647
+ {
648
+ "recommendations": ["CucumberOpen.cucumber-official"]
649
+ }
650
+ ```
651
+
652
+ **settings.json**
653
+
654
+ ```json
655
+ {
656
+ "cucumber.glue": [
657
+ "tests/steps/*.{ts,js}",
658
+ "node_modules/artes/src/tests/stepDefinitions/*.{ts,js}"
659
+ ],
660
+ "cucumber.features": ["tests/features/*.features"],
661
+ "cucumberautocomplete.syncfeatures": true,
662
+ "cucumberautocomplete.strictGherkinCompletion": true
663
+ }
664
+ ```
665
+
666
+ ---
667
+
668
+ ## ๐Ÿง‘โ€๐Ÿ’ป Have a Good Testing