@argos-ci/cypress 7.0.21 → 7.1.0

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
@@ -17,7 +17,7 @@
17
17
 
18
18
  Capture stable Argos screenshots from your [Cypress](https://www.cypress.io/) tests.
19
19
 
20
- Visit the [Cypress SDK documentation](https://argos-ci.com/docs/sdks-reference/cypress) for guides, the API reference, and more.
20
+ Visit the [Cypress SDK documentation](https://argos-ci.com/docs/reference/cypress) for guides, the API reference, and more.
21
21
 
22
22
  ## Installation
23
23
 
@@ -69,6 +69,6 @@ describe("Homepage", () => {
69
69
 
70
70
  ## Links
71
71
 
72
- - [Official SDK Docs](https://argos-ci.com/docs/sdks-reference/cypress)
72
+ - [Official SDK Docs](https://argos-ci.com/docs/reference/cypress)
73
73
  - [Quickstart](https://argos-ci.com/docs/quickstart/cypress-quickstart)
74
74
  - [Discord](https://argos-ci.com/discord)
@@ -16,6 +16,22 @@ type ArgosScreenshotOptions = Partial<Cypress.Loggable & Cypress.Timeoutable & C
16
16
  * @default 0.5
17
17
  */
18
18
  threshold?: number;
19
+ /**
20
+ * Name, or list of names, to compare this screenshot against instead of its
21
+ * own name. A list is tried in order and the first name found in the baseline
22
+ * build wins, which lets a brand new screenshot fall back to an existing one
23
+ * rather than showing up as added.
24
+ *
25
+ * The screenshot's own name is not implicitly included: list it first to keep
26
+ * comparing against itself when it exists.
27
+ *
28
+ * @example
29
+ * // Compare "home-variant-b" against itself, or against "home" if it is new.
30
+ * cy.argosScreenshot("home-variant-b", {
31
+ * baseName: ["home-variant-b", "home"],
32
+ * })
33
+ */
34
+ baseName?: string | string[];
19
35
  /**
20
36
  * Wait for the UI to stabilize before taking the screenshot.
21
37
  * Set to `false` to disable stabilization.
@@ -34,7 +50,7 @@ declare global {
34
50
  /**
35
51
  * Stabilize the UI and takes a screenshot of the application under test.
36
52
  *
37
- * @see https://argos-ci.com/docs/sdks-reference/cypress
53
+ * @see https://argos-ci.com/docs/reference/cypress
38
54
  * @example
39
55
  * cy.argosScreenshot("my-screenshot")
40
56
  * cy.get(".post").argosScreenshot()
package/dist/support.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import "cypress-wait-until";
2
2
  import { getGlobalScript, resolveViewport } from "@argos-ci/browser";
3
- import { getMetadataPath, getScreenshotName, validateThreshold } from "@argos-ci/util/browser";
3
+ import { getMetadataPath, getScreenshotName, normalizeBaseNames, validateThreshold } from "@argos-ci/util/browser";
4
4
  //#region package.json
5
- var version = "7.0.20";
5
+ var version = "7.0.22";
6
6
  //#endregion
7
7
  //#region src/shared.ts
8
8
  /**
@@ -73,7 +73,8 @@ Cypress.Commands.add("argosScreenshot", { prevSubject: [
73
73
  "window",
74
74
  "document"
75
75
  ] }, (subject, name, options = {}) => {
76
- const { viewports, argosCSS: _argosCSS, tag, ...cypressOptions } = options;
76
+ const { viewports, argosCSS: _argosCSS, tag, baseName, ...cypressOptions } = options;
77
+ const baseNames = normalizeBaseNames(baseName);
77
78
  if (!name) throw new Error("The `name` argument is required.");
78
79
  Cypress.log({
79
80
  name: "argosScreenshot",
@@ -82,7 +83,7 @@ Cypress.Commands.add("argosScreenshot", { prevSubject: [
82
83
  });
83
84
  injectArgos();
84
85
  const afterAll = beforeAll(options);
85
- function stabilizeAndScreenshot(name) {
86
+ function stabilizeAndScreenshot(name, baseNames) {
86
87
  waitForReadiness(options);
87
88
  const afterEach = beforeEach(options);
88
89
  waitForReadiness(options);
@@ -125,6 +126,7 @@ Cypress.Commands.add("argosScreenshot", { prevSubject: [
125
126
  }
126
127
  };
127
128
  metadata.transient = {};
129
+ if (baseNames) metadata.transient.baseName = baseNames;
128
130
  if (tag) metadata.tags = Array.isArray(tag) ? tag : [tag];
129
131
  if (options.threshold !== void 0) {
130
132
  validateThreshold(options.threshold);
@@ -138,10 +140,10 @@ Cypress.Commands.add("argosScreenshot", { prevSubject: [
138
140
  for (const viewport of viewports) {
139
141
  const viewportSize = resolveViewport(viewport);
140
142
  cy.viewport(viewportSize.width, viewportSize.height);
141
- stabilizeAndScreenshot(getScreenshotName(name, { viewportWidth: viewportSize.width }));
143
+ stabilizeAndScreenshot(getScreenshotName(name, { viewportWidth: viewportSize.width }), baseNames?.map((baseName) => getScreenshotName(baseName, { viewportWidth: viewportSize.width })) ?? null);
142
144
  }
143
145
  cy.viewport(Cypress.config("viewportWidth"), Cypress.config("viewportHeight"));
144
- } else stabilizeAndScreenshot(name);
146
+ } else stabilizeAndScreenshot(name, baseNames);
145
147
  afterAll();
146
148
  });
147
149
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/cypress",
3
3
  "description": "Cypress SDK for visual testing with Argos.",
4
- "version": "7.0.21",
4
+ "version": "7.1.0",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -9,7 +9,7 @@
9
9
  "url": "https://github.com/argos-ci/argos-javascript.git",
10
10
  "directory": "packages/cypress"
11
11
  },
12
- "homepage": "https://argos-ci.com/docs/sdks-reference/cypress",
12
+ "homepage": "https://argos-ci.com/docs/reference/cypress",
13
13
  "bugs": {
14
14
  "url": "https://github.com/argos-ci/argos-javascript/issues"
15
15
  },
@@ -45,8 +45,8 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@argos-ci/browser": "6.4.4",
48
- "@argos-ci/core": "6.6.1",
49
- "@argos-ci/util": "4.0.4",
48
+ "@argos-ci/core": "6.7.0",
49
+ "@argos-ci/util": "4.1.0",
50
50
  "cypress-wait-until": "^3.0.2"
51
51
  },
52
52
  "peerDependencies": {
@@ -66,5 +66,5 @@
66
66
  "check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
67
67
  "lint": "eslint ."
68
68
  },
69
- "gitHead": "e6b1b39775bc210c6b8fec81c59165c5a4aa4dc9"
69
+ "gitHead": "a3083087b11004e0b315e2d14f1e9179cbd56da2"
70
70
  }