artes 1.0.4 → 1.0.7

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 CHANGED
@@ -1,8 +1,12 @@
1
+ <p align="center">
2
+ <img alt="madge" src="https://github.com/user-attachments/assets/e0641011-0e96-4330-8ad5-935b395b0838" width="280">
3
+ </p>
4
+
1
5
  <h1 align="center">Artes</h1>
2
6
 
3
7
  ## 🚀 Summary
4
8
 
5
- Artes is a test runner for Playwright that executes [predefined Cucumber tests](./stepDefinitions.md) and can generate Allure reports for test results. It simplifies the process of 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.
9
+ Artes is a test runner for Playwright that executes [predefined Cucumber tests](./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.
6
10
 
7
11
  ## 🧑‍💻 Installation
8
12
 
@@ -43,6 +47,8 @@ npx artes [options]
43
47
  | 🏗️ `-c, --create` | Create an example project with Artes | `artes -c` or `artes --create` |
44
48
  | ✅ `-y, --yes` | Skip the confirmation prompt when creating an example project | `artes -c -y` or `artes --create --yes` |
45
49
  | 📊 `-r, --report` | Run tests and generate Allure report | `artes -r` or `artes --report` |
50
+ | 🕵️‍♂️ `-t, --trace` | Run tests with trace and open trace viewer | `artes -t` or `artes --trace` |
51
+
46
52
 
47
53
  \*\* To just run the tests: <br>
48
54
  Globally: artes <br>
@@ -53,7 +59,7 @@ Locally: npx artes
53
59
  ## 🎯 Best Practices
54
60
 
55
61
  - **Global Installation:**
56
- For ease of use, it's recommended to install Artes globally. You can do this by running the following command:
62
+ For ease of use, it's recommended that Artes be installed globally. You can do this by running the following command:
57
63
 
58
64
  ```bash
59
65
  npm install -g artes
@@ -2,12 +2,12 @@ const fs = require("fs");
2
2
  const path = require("path");
3
3
  const { moduleConfig } = require("./src/helper/imports/commons");
4
4
 
5
- let argusConfig = {};
5
+ let artesConfig = {};
6
6
 
7
7
  try {
8
8
  if (fs.existsSync(moduleConfig.cucumberConfigPath)) {
9
- const argusConf = require(moduleConfig.cucumberConfigPath);
10
- argusConfig = argusConf || {};
9
+ const artesConf = require(moduleConfig.cucumberConfigPath);
10
+ artesConfig = artesConf || {};
11
11
  }
12
12
  } catch (error) {
13
13
  console.warn("Error reading config file:", error.message);
@@ -17,67 +17,67 @@ try {
17
17
  module.exports = {
18
18
  default: {
19
19
  // File paths and patterns
20
- cucumberTimeout: argusConfig.cucumberTimeout || 5000, // Default timeout in milliseconds
21
- paths: argusConfig.features
22
- ? path.join(moduleConfig.projectPath, argusConfig.features)
20
+ cucumberTimeout: artesConfig.cucumberTimeout || 30, // Default timeout in milliseconds
21
+ paths: artesConfig.features
22
+ ? path.join(moduleConfig.projectPath, artesConfig.features)
23
23
  : [moduleConfig.featuresPath], // Paths to feature files
24
24
  require: [
25
- argusConfig.steps
26
- ? path.join(moduleConfig.projectPath, argusConfig.steps)
25
+ artesConfig.steps
26
+ ? path.join(moduleConfig.projectPath, artesConfig.steps)
27
27
  : moduleConfig.stepsPath,
28
28
  "src/tests/stepDefinitions/*.js",
29
29
  "src/hooks/hooks.js",
30
30
  ], // Support code paths (CommonJS)
31
- pomPath: argusConfig.pomPath
32
- ? path.join(moduleConfig.projectPath, argusConfig.pomPath)
31
+ pomPath: artesConfig.pomPath
32
+ ? path.join(moduleConfig.projectPath, artesConfig.pomPath)
33
33
  : moduleConfig.pomPath,
34
- import: argusConfig.import || [], // Support code paths
34
+ import: artesConfig.import || [], // Support code paths
35
35
 
36
36
  // Formatting and output
37
- format: argusConfig.format || [
37
+ format: artesConfig.format || [
38
38
  "rerun:@rerun.txt",
39
39
  "allure-cucumberjs/reporter",
40
40
  ], // Formatter names/paths
41
- formatOptions: argusConfig.formatOptions || {
41
+ formatOptions: artesConfig.formatOptions || {
42
42
  resultsDir: `allure-result`,
43
43
  }, // Formatter options
44
44
 
45
45
  // Execution options
46
- parallel: argusConfig.parallel || 1, // Number of parallel workers
47
- dryRun: argusConfig.dryRun || false, // Prepare test run without execution
48
- failFast: argusConfig.failFast || false, // Stop on first test failure
49
- forceExit: argusConfig.forceExit || false, // Force process.exit() after tests
50
- strict: argusConfig.strict || true, // Fail on pending steps
51
- backtrace: argusConfig.backtrace || false, // Show full backtrace for errors
46
+ parallel: artesConfig.parallel || 1, // Number of parallel workers
47
+ dryRun: artesConfig.dryRun || false, // Prepare test run without execution
48
+ failFast: artesConfig.failFast || false, // Stop on first test failure
49
+ forceExit: artesConfig.forceExit || false, // Force process.exit() after tests
50
+ strict: artesConfig.strict || true, // Fail on pending steps
51
+ backtrace: artesConfig.backtrace || false, // Show full backtrace for errors
52
52
 
53
53
  // Filtering and organization
54
- tags: argusConfig.tags || process.env.npm_config_TAGS || "", // Tag expression to filter scenarios
55
- name: argusConfig.name || [], // Run scenarios matching regex
56
- order: argusConfig.order || "defined", // Run order (defined/random)
57
- language: argusConfig.language || "en", // Default feature file language
54
+ tags: artesConfig.tags || process.env.npm_config_TAGS || "", // Tag expression to filter scenarios
55
+ name: artesConfig.name || [], // Run scenarios matching regex
56
+ order: artesConfig.order || "defined", // Run order (defined/random)
57
+ language: artesConfig.language || "en", // Default feature file language
58
58
 
59
59
  // Module loading
60
- loader: argusConfig.loader || [], // Module loader specifications
61
- requireModule: argusConfig.requireModule || [], // Transpilation module names
60
+ loader: artesConfig.loader || [], // Module loader specifications
61
+ requireModule: artesConfig.requireModule || [], // Transpilation module names
62
62
 
63
63
  // Retry logic
64
- retry: argusConfig.retry || 0, // Retry attempts for failing tests
65
- retryTagFilter: argusConfig.retryTagFilter || "", // Tag expression for retries
64
+ retry: artesConfig.retry || 0, // Retry attempts for failing tests
65
+ retryTagFilter: artesConfig.retryTagFilter || "", // Tag expression for retries
66
66
 
67
67
  // Publishing
68
- publish: argusConfig.publish || false, // Publish to cucumber.io
68
+ publish: artesConfig.publish || false, // Publish to cucumber.io
69
69
 
70
70
  // World parameters
71
- worldParameters: argusConfig.worldParameters || {}, // Custom world parameters
71
+ worldParameters: artesConfig.worldParameters || {}, // Custom world parameters
72
72
  },
73
73
 
74
74
  browser: {
75
- browserType: argusConfig.browserType || "chrome",
75
+ browserType: artesConfig.browserType || "chrome",
76
76
  viewport: {
77
- width: argusConfig.viewport?.width || 1280,
78
- height: argusConfig.viewport?.height || 720,
77
+ width: artesConfig.viewport?.width || 1280,
78
+ height: artesConfig.viewport?.height || 720,
79
79
  },
80
- headless: argusConfig.headless !== undefined ? argusConfig.headless : true,
80
+ headless: artesConfig.headless !== undefined ? artesConfig.headless : true,
81
81
  },
82
82
 
83
83
  ci: {
package/executer.js CHANGED
@@ -1,10 +1,7 @@
1
1
  #!/usr/bin/env node
2
- const { showHelp } = require("./src/helper/executers/helper");
3
- const { showVersion } = require("./src/helper/executers/versionChecker");
4
- const { createProject } = require("./src/helper/executers/projectCreator");
5
- const { runTests } = require("./src/helper/executers/testRunner");
6
- const { generateReport } = require("./src/helper/executers/reportGenerator");
7
- const { cleanUp } = require("./src/helper/executers/cleaner");
2
+
3
+ const { showHelp,showVersion,createProject,runTests,generateReport,cleanUp,tracer } = require("./src/helper/executers/exporter");
4
+
8
5
 
9
6
  const args = process.argv.slice(2);
10
7
 
@@ -14,9 +11,12 @@ const flags = {
14
11
  create: args.includes("-c") || args.includes("--create"),
15
12
  createYes: args.includes("-y") || args.includes("--yes"),
16
13
  report: args.includes("-r") || args.includes("--report"),
14
+ trace: args.includes("-t") || args.includes("--trace"),
17
15
  };
18
16
 
19
17
  function main() {
18
+
19
+
20
20
  if (flags.help) {
21
21
  showHelp();
22
22
  return;
@@ -32,6 +32,18 @@ function main() {
32
32
  return;
33
33
  }
34
34
 
35
+ if (flags.trace) {
36
+ runTests();
37
+ tracer();
38
+ cleanUp();
39
+ }
40
+ if (flags.report && flags.trace) {
41
+ runTests();
42
+ generateReport();
43
+ tracer();
44
+ cleanUp();
45
+ }
46
+
35
47
  if (flags.report) {
36
48
  runTests();
37
49
  generateReport();
@@ -43,3 +55,7 @@ function main() {
43
55
  }
44
56
 
45
57
  main();
58
+
59
+ module.exports = {
60
+ flags
61
+ }
@@ -393,16 +393,51 @@ await navigateTo("https://example.com");
393
393
 
394
394
  ---
395
395
 
396
+ #### `navigateBack()`
397
+
398
+ Navigates to the previous page.
399
+
400
+ ```javascript
401
+ navigateBack();
402
+ ```
403
+
404
+ ---
405
+
406
+ #### `navigateForward()`
407
+
408
+ Navigates to the next page.
409
+
410
+ ```javascript
411
+ navigateForward();
412
+ ```
413
+
414
+ ---
415
+
396
416
  #### `getURL()`
397
417
 
398
418
  Retrieves the current URL of the page.
399
419
 
400
420
  ```javascript
401
- const currentURL = await getURL();
421
+ await getURL();
402
422
  ```
403
423
 
404
424
  - **Returns**:
405
425
  - _(string)_: The current page URL.
426
+
427
+ ---
428
+
429
+ #### `wait()`
430
+
431
+ Waits on the page until specified times.
432
+
433
+ ```javascript
434
+ await wait(time);
435
+ ```
436
+ - **Parameters**:
437
+ - `time` _(int)_: millisecond.
438
+
439
+ ---
440
+
406
441
 
407
442
  ### **Assertion Functions**
408
443
 
package/index.js CHANGED
@@ -14,7 +14,7 @@ const {
14
14
  frame,
15
15
  assert,
16
16
  elementInteractions,
17
- } = require("./src/helper/stepFunctions/actionCommons");
17
+ } = require("./src/helper/stepFunctions/exporter");
18
18
 
19
19
  module.exports = {
20
20
  expect,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "description": "The package provide step definitions and user writes feature files, and the package handles automation, with optional POM files and custom step definitions.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -13,9 +13,7 @@ function cleanUp() {
13
13
  },
14
14
  );
15
15
 
16
- if (result.error) {
17
- throw result.error;
18
- }
16
+
19
17
  } catch (error) {
20
18
  console.error("❌ Error in cleanup:", error.message);
21
19
  process.exit(1);
@@ -0,0 +1,17 @@
1
+ const { showHelp } = require("./helper");
2
+ const { createProject } = require("./projectCreator");
3
+ const { generateReport } = require("./reportGenerator");
4
+ const { runTests } = require("./testRunner");
5
+ const { tracer } = require("./tracer");
6
+ const { showVersion } = require("./versionChecker");
7
+ const { cleanUp } = require("./cleaner");
8
+
9
+ module.exports = {
10
+ createProject,
11
+ generateReport,
12
+ runTests,
13
+ showHelp,
14
+ showVersion,
15
+ tracer,
16
+ cleanUp
17
+ }
@@ -40,26 +40,27 @@ function createProject(createYes) {
40
40
 
41
41
  // Configuration options:
42
42
  // paths: [], // string[] - Paths to feature files
43
- // require: "", // string - Step definitions files
43
+ // steps: "", // string - Step definitions files
44
44
  // pomPath: "", // string - Path to POM files
45
+ // timeout : 0 // number - Test timeout in seconds
46
+ // parallel: 0, // number - Number of parallel workers
47
+ // format: [], // string[] - Formatter names/paths
48
+ // formatOptions: {}, // object - Formatter options
49
+ // retry: 0, // number - Retry attempts for failing tests
50
+ // tags: "", // string - Tag expression to filter scenarios
45
51
  // backtrace: false, // boolean - Show full backtrace for errors
46
52
  // dryRun: false, // boolean - Prepare test run without execution
47
53
  // forceExit: false, // boolean - Force process.exit() after tests
48
54
  // failFast: false, // boolean - Stop on first test failure
49
- // format: [], // string[] - Formatter names/paths
50
- // formatOptions: {}, // object - Formatter options
51
55
  // import: [], // string[] - Support code paths
52
56
  // language: "en", // string - Default feature file language
53
57
  // loader: [], // string[] - Module loader specifications
54
58
  // name: [], // string[] - Run scenarios matching regex
55
59
  // order: "defined", // string - Run order (defined/random)
56
- // parallel: 0, // number - Number of parallel workers
57
60
  // publish: false, // boolean - Publish to cucumber.io
58
61
  // requireModule: [], // string[] - Transpilation module names
59
- // retry: 0, // number - Retry attempts for failing tests
60
62
  // retryTagFilter: "", // string - Tag expression for retries
61
63
  // strict: true, // boolean - Fail on pending steps
62
- // tags: "", // string - Tag expression to filter scenarios
63
64
  // worldParameters: {} // object - World constructor parameters
64
65
  };
65
66
  `;
@@ -15,10 +15,6 @@ function generateReport() {
15
15
  },
16
16
  );
17
17
 
18
- if (result.error) {
19
- throw result.error;
20
- }
21
-
22
18
  console.log(
23
19
  `📋 Report generated successfully in ${moduleConfig.reportPath}!`,
24
20
  );
@@ -19,9 +19,6 @@ function runTests() {
19
19
  },
20
20
  });
21
21
 
22
- if (result.error) {
23
- throw result.error;
24
- }
25
22
 
26
23
  console.log("✅ Tests completed successfully!");
27
24
  } catch (error) {
@@ -0,0 +1,24 @@
1
+ const { spawnSync } = require("child_process");
2
+ const { moduleConfig } = require("../imports/commons");
3
+
4
+
5
+ function tracer() {
6
+ try {
7
+ console.log("🕵️‍♂️ Tracer is generating...");
8
+
9
+ const result = spawnSync("npx", ["playwright", "show-trace", '/trace.zip'], {
10
+ cwd: moduleConfig.modulePath,
11
+ stdio: "inherit",
12
+ shell: true
13
+ });
14
+
15
+ console.log("✅ Trace viewer is opened!");
16
+ } catch (error) {
17
+ console.error("❌ Test execution failed:", error);
18
+ process.exit(1);
19
+ }
20
+ }
21
+
22
+ module.exports = {
23
+ tracer,
24
+ };
@@ -16,6 +16,7 @@ const moduleConfig = {
16
16
  modulePackageJsonPath: path.join(modulePath, "/package.json"),
17
17
  modulePath: path.join(modulePath, "/node_modules/artes"),
18
18
  reportPath: path.join(modulePath, "/report"),
19
+ tracerPath: path.join(projectPath, "/trace.zip"),
19
20
  cucumberConfigPath: path.join(projectPath, "/artes.config.js"),
20
21
  featuresPath: path.join(projectPath, "/tests/features/"),
21
22
  stepsPath: path.join(projectPath, "/tests/steps/*.js"),
@@ -7,6 +7,15 @@ const page = {
7
7
  getURL: async () => {
8
8
  return await context.page.url();
9
9
  },
10
+ navigateBack:async () => {
11
+ return await context.page.goBack();
12
+ },
13
+ navigateForward:async () => {
14
+ return await context.page.goForward();
15
+ },
16
+ wait: async (time) => {
17
+ return await context.page.waitForTimeout(time);
18
+ },
10
19
  };
11
20
 
12
21
  module.exports = {
@@ -8,15 +8,16 @@ const {
8
8
  } = require("@cucumber/cucumber");
9
9
  const { invokeBrowser } = require("../helper/contextManager/browserManager");
10
10
  const { invokeRequest } = require("../helper/contextManager/requestManager");
11
- const { context } = require("./context");
12
11
  const { pomCollector } = require("../helper/pomController/pomCollector");
13
- const fs = require("fs");
14
12
  const cucumberConfig = require("../../cucumber.config");
13
+ const { flags } = require("../../executer");
14
+ const { context } = require("./context");
15
+ const fs = require("fs");
15
16
 
16
17
  let browser;
17
18
  let request;
18
19
 
19
- setDefaultTimeout(cucumberConfig.default.cucumberTimeout);
20
+ setDefaultTimeout(cucumberConfig.default.cucumberTimeout * 1000);
20
21
 
21
22
  BeforeAll(async function () {
22
23
  browser = await invokeBrowser();
@@ -24,7 +25,7 @@ BeforeAll(async function () {
24
25
 
25
26
  pomCollector();
26
27
 
27
- browser.tracing.start({
28
+ flags.trace && browser.tracing.start({
28
29
  sources: true,
29
30
  screenshots: true,
30
31
  snapshots: true,
@@ -50,8 +51,6 @@ After(async function ({ pickle, result }) {
50
51
  this.attach(img, "image/png");
51
52
  }
52
53
 
53
- await browser.tracing.stop({ path: "./trace.zip" });
54
-
55
54
  await context.page.close();
56
55
 
57
56
  if (result?.status == Status.FAILED) {
@@ -63,5 +62,5 @@ After(async function ({ pickle, result }) {
63
62
 
64
63
  AfterAll(function () {
65
64
  browser.close();
66
- browser.tracing.stop({ path: "../../trace.zip" });
65
+ flags.trace && browser.tracing.stop({ path: '/trace.zip' });
67
66
  });
@@ -1,5 +1,5 @@
1
1
  const { Then } = require("../../helper/imports/commons");
2
- const { assert } = require("../../helper/stepFunctions/actionCommons");
2
+ const { assert } = require("../../helper/stepFunctions/exporter");
3
3
 
4
4
  // Check if a selector should be attached
5
5
  Then("User expects {string} should be attached", function (selector) {
@@ -1,5 +1,5 @@
1
1
  const { When } = require("../../helper/imports/commons");
2
- const { frame } = require("../../helper/stepFunctions/actionCommons");
2
+ const { frame } = require("../../helper/stepFunctions/exporter");
3
3
 
4
4
  // User takes a screenshot of a specific selector
5
5
  When("User takes a screenshot of {string}", async function (selector) {
@@ -1,5 +1,5 @@
1
1
  const { When } = require("../../helper/imports/commons");
2
- const { keyboard } = require("../../helper/stepFunctions/actionCommons");
2
+ const { keyboard } = require("../../helper/stepFunctions/exporter");
3
3
 
4
4
  // User presses a key on a specific selector
5
5
  When("User presses {string} on {string}", async function (key, selector) {
@@ -1,5 +1,5 @@
1
1
  const { When } = require("../../helper/imports/commons");
2
- const { mouse } = require("../../helper/stepFunctions/actionCommons");
2
+ const { mouse } = require("../../helper/stepFunctions/exporter");
3
3
 
4
4
  // User clicks on a selector
5
5
  When("User clicks {string}", async function (selector) {
@@ -1,5 +1,5 @@
1
1
  const { When, context } = require("../../helper/imports/commons");
2
- const { page } = require("../../helper/stepFunctions/actionCommons");
2
+ const { page } = require("../../helper/stepFunctions/exporter");
3
3
 
4
4
  When("User navigates to {string} page", async function (url) {
5
5
  await page.navigateTo(url);
@@ -9,8 +9,12 @@ When("User navigates to {string} page", async function (url) {
9
9
  // await page.navigateTo(url);
10
10
  // });
11
11
 
12
- When("User gets URL of page", async function () {
13
- await page.getURL();
12
+ When("User navigates previous page", async function () {
13
+ await page.navigateBack();
14
+ });
15
+
16
+ When("User navigates next page", async function () {
17
+ await page.navigateForward();
14
18
  });
15
19
 
16
20
  When("User gets URL of page", async function () {
@@ -18,13 +22,13 @@ When("User gets URL of page", async function () {
18
22
  });
19
23
 
20
24
  When(`User waits {int} seconds`, async (sec) => {
21
- await context.page.waitForTimeout(sec * 1000);
25
+ await page.wait(sec * 1000);
22
26
  });
23
27
 
24
28
  When(`User waits {int} milliseconds`, async (sec) => {
25
- await context.page.waitForTimeout(sec);
29
+ await page.wait(sec);
26
30
  });
27
31
 
28
32
  When(`User waits {int} minutes`, async (sec) => {
29
- await context.page.waitForTimeout(sec * 1000 * 60);
33
+ await page.wait(sec * 1000 * 60);
30
34
  });
@@ -110,6 +110,8 @@
110
110
  ### Navigation Actions
111
111
 
112
112
  - User navigates to `{string}` page
113
+ - User navigates previous page
114
+ - User navigates next page
113
115
 
114
116
  ### URL Actions
115
117