artes 1.7.4 → 1.7.5

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
@@ -147,6 +147,8 @@ npx artes [options]
147
147
  | `-h, --help` | Show this help message | `artes -h` or `artes --help` |
148
148
  | `-v, --version` | Show current version of artes | `artes -v` or `artes --version` |
149
149
  | `-c, --create` | Create example artes project | `artes -c` or `artes --create` |
150
+ | `-y, --yes` | Skip confirmation prompt when creating a project | `artes -c -y` or `artes -c --yes` |
151
+ | `--noDeps` | Create project without installing dependencies | `artes -c --noDeps` |
150
152
 
151
153
  ### Reporting & Branding ( artes report --help )
152
154
 
package/executer.js CHANGED
@@ -45,6 +45,8 @@ const flags = {
45
45
  help: args.includes("-h") || args.includes("--help"),
46
46
  version: args.includes("-v") || args.includes("--version"),
47
47
  create: args.includes("-c") || args.includes("--create"),
48
+ createYes: args.includes("-y") || args.includes("--yes"),
49
+ noDeps: args.includes("--noDeps"),
48
50
 
49
51
  // Sub-command help pages
50
52
  reportHelp: (args[0] === "report" && args.includes("--help")),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artes",
3
- "version": "1.7.4",
3
+ "version": "1.7.5",
4
4
  "description": "The simplest way to automate UI and API tests using Cucumber-style steps.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,31 +8,30 @@ const { PNG } = require("pngjs");
8
8
  const { moduleConfig } = require("artes/src/helper/imports/commons");
9
9
 
10
10
  async function screenComparer(baselineFilename, screenshotFn, options = {}) {
11
- const { maxDiffPercent = 0.01, threshold = 0.1 } = options;
11
+ const { maxDiffPercent = 0.01, threshold = 0.1, comparePath } = options;
12
12
 
13
13
  const baselinePath = path.join(moduleConfig.projectPath, baselineFilename);
14
- const actualPath = path.join(
15
- moduleConfig.projectPath,
16
- "visualComparison",
17
- `actual_${baselineFilename}`,
18
- );
14
+
15
+ const actualPath = comparePath
16
+ ? path.join(moduleConfig.projectPath, comparePath)
17
+ : path.join(moduleConfig.projectPath, "visualComparison", `actual_${baselineFilename}`);
18
+
19
19
  const diffPath = path.join(
20
20
  moduleConfig.projectPath,
21
21
  "visualComparison",
22
22
  `diff_${baselineFilename}`,
23
23
  );
24
24
 
25
- await screenshotFn(actualPath);
26
-
27
- const baselineMeta = await sharp(baselinePath).metadata();
28
- const actualMeta = await sharp(actualPath).metadata();
25
+ const visualComparisonDir = path.join(moduleConfig.projectPath, "visualComparison");
26
+ if (!fs.existsSync(visualComparisonDir)) {
27
+ fs.mkdirSync(visualComparisonDir, { recursive: true });
28
+ }
29
29
 
30
- // if (baselineMeta.width !== actualMeta.width || baselineMeta.height !== actualMeta.height) {
31
- // console.warn(`⚠️ Dimension mismatch! Baseline: ${baselineMeta.width}x${baselineMeta.height} | Actual: ${actualMeta.width}x${actualMeta.height}`);
32
- // }
30
+ if (!comparePath) {
31
+ await screenshotFn(actualPath);
32
+ }
33
33
 
34
- const width = actualMeta.width;
35
- const height = actualMeta.height;
34
+ const { width, height } = await sharp(actualPath).metadata();
36
35
 
37
36
  const baselineBuffer = await sharp(baselinePath)
38
37
  .resize(width, height, { fit: "fill" })
@@ -59,44 +58,34 @@ async function screenComparer(baselineFilename, screenshotFn, options = {}) {
59
58
 
60
59
  fs.writeFileSync(diffPath, PNG.sync.write(diffImg));
61
60
 
62
- const totalPixels = width * height;
61
+ const totalPixels = width * height;
63
62
  const mismatchRatio = mismatchedPixels / totalPixels;
64
63
 
65
- const expectedBase64 = (
66
- await sharp(baselinePath)
67
- .resize(width, height, { fit: "fill" })
68
- .png()
69
- .toBuffer()
70
- ).toString("base64");
71
- const actualBase64 = (await sharp(actualPath).png().toBuffer()).toString(
72
- "base64",
73
- );
74
- const diffBase64 = (await sharp(diffPath).png().toBuffer()).toString(
75
- "base64",
76
- );
64
+ const expectedBase64 = (await sharp(baselinePath).resize(width, height, { fit: "fill" }).png().toBuffer()).toString("base64");
65
+ const actualBase64 = (await sharp(actualPath).png().toBuffer()).toString("base64");
66
+ const diffBase64 = (await sharp(diffPath).png().toBuffer()).toString("base64");
77
67
 
78
68
  const content = JSON.stringify({
79
69
  expected: `data:image/png;base64,${expectedBase64}`,
80
- actual: `data:image/png;base64,${actualBase64}`,
81
- diff: `data:image/png;base64,${diffBase64}`,
70
+ actual: `data:image/png;base64,${actualBase64}`,
71
+ diff: `data:image/png;base64,${diffBase64}`,
82
72
  });
83
73
 
84
74
  await allure.attachment(
85
75
  "Screenshot diff details",
86
- ` Mismatched pixels: ${mismatchedPixels} / ${totalPixels} (${(mismatchRatio * 100).toFixed(2)}%) Max allowed: ${maxDiffPercent * 100}%`,
76
+ `Mismatched pixels: ${mismatchedPixels} / ${totalPixels} (${(mismatchRatio * 100).toFixed(2)}%) Max allowed: ${maxDiffPercent * 100}%`,
87
77
  "text/plain",
88
78
  );
79
+
89
80
  await allure.attachment(
90
81
  "Screenshot diff",
91
82
  content,
92
83
  "application/vnd.allure.image.diff",
93
84
  );
94
85
 
95
- if (fs.existsSync(path.join(moduleConfig.projectPath, "visualComparison")))
96
- fs.rmSync(path.join(moduleConfig.projectPath, "visualComparison"), {
97
- recursive: true,
98
- force: true,
99
- });
86
+ if (fs.existsSync(visualComparisonDir)) {
87
+ fs.rmSync(visualComparisonDir, { recursive: true, force: true });
88
+ }
100
89
 
101
90
  if (mismatchRatio > maxDiffPercent) {
102
91
  throw new Error(
@@ -105,4 +94,4 @@ async function screenComparer(baselineFilename, screenshotFn, options = {}) {
105
94
  }
106
95
  }
107
96
 
108
- module.exports = { screenComparer };
97
+ module.exports = { screenComparer };
@@ -9,6 +9,8 @@ function showHelp() {
9
9
  -h, --help Show this help message
10
10
  -v, --version Show current version of artes
11
11
  -c, --create Create example artes project
12
+ -y, --yes Skip confirmation prompt when creating a project
13
+ --noDeps Create project without installing dependencies
12
14
 
13
15
  For more options, use:
14
16
  artes report --help Reporting & branding options
@@ -9,7 +9,7 @@ const {
9
9
  } = require("../helper/imports/commons");
10
10
  const {
11
11
  screenComparer,
12
- } = require("artes/src/helper/controller/screenComparer");
12
+ } = require("../helper/controller/screenComparer");
13
13
  const { assert, frame } = require("../helper/stepFunctions/exporter");
14
14
  const Ajv = require("ajv");
15
15
 
@@ -399,6 +399,29 @@ Then(
399
399
  },
400
400
  );
401
401
 
402
+
403
+ Then(
404
+ "User expects that {string} screenshot match with {string} screenshot",
405
+ async function (ss1, ss2) {
406
+ await screenComparer(
407
+ ss1,
408
+ null,
409
+ { maxDiffPercent: 0.01, comparePath: ss2 },
410
+ );
411
+ },
412
+ );
413
+
414
+ Then(
415
+ "User expects that {string} screenshot match with {string} screenshot with {float}% difference",
416
+ async function (ss1, ss2, maxDiff) {
417
+ await screenComparer(
418
+ ss1,
419
+ null,
420
+ { maxDiffPercent: maxDiff / 100, comparePath: ss2 },
421
+ );
422
+ },
423
+ );
424
+
402
425
  // Check if a selector should have specific text
403
426
  Then(
404
427
  "User expects {string} should match {string} text",