@argos-ci/cypress 3.4.0 → 4.0.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/dist/support.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ViewportOption, StabilizationOptions } from '@argos-ci/browser';
1
+ import { ViewportOption, StabilizationPluginOptions } from '@argos-ci/browser';
2
2
 
3
3
  type ArgosScreenshotOptions = Partial<Cypress.Loggable & Cypress.Timeoutable & Cypress.ScreenshotOptions> & {
4
4
  /**
@@ -21,7 +21,7 @@ type ArgosScreenshotOptions = Partial<Cypress.Loggable & Cypress.Timeoutable & C
21
21
  * Pass an object to customize the stabilization.
22
22
  * @default true
23
23
  */
24
- stabilize?: boolean | StabilizationOptions;
24
+ stabilize?: boolean | StabilizationPluginOptions;
25
25
  };
26
26
  declare global {
27
27
  namespace Cypress {
package/dist/support.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  } from "@argos-ci/util/browser";
12
12
 
13
13
  // package.json
14
- var version = "3.3.3";
14
+ var version = "3.4.0";
15
15
 
16
16
  // src/support.ts
17
17
  function injectArgos() {
@@ -22,14 +22,19 @@ function injectArgos() {
22
22
  window.eval(getGlobalScript());
23
23
  });
24
24
  }
25
- function beforeAll(options) {
25
+ function getStabilizationContext(options) {
26
26
  const { argosCSS } = options;
27
27
  const fullPage = !options.capture || options.capture === "fullPage";
28
+ return {
29
+ fullPage,
30
+ argosCSS,
31
+ options: options.stabilize
32
+ };
33
+ }
34
+ function beforeAll(options) {
35
+ const context = getStabilizationContext(options);
28
36
  cy.window({ log: false }).then(
29
- (window) => window.__ARGOS__.beforeAll({
30
- fullPage,
31
- argosCSS
32
- })
37
+ (window) => window.__ARGOS__.beforeAll(context)
33
38
  );
34
39
  return () => {
35
40
  cy.window({ log: false }).then(
@@ -38,13 +43,9 @@ function beforeAll(options) {
38
43
  };
39
44
  }
40
45
  function beforeEach(options) {
41
- const { argosCSS } = options;
42
- const fullPage = !options.capture || options.capture === "fullPage";
46
+ const context = getStabilizationContext(options);
43
47
  cy.window({ log: false }).then(
44
- (window) => window.__ARGOS__.beforeEach({
45
- fullPage,
46
- argosCSS
47
- })
48
+ (window) => window.__ARGOS__.beforeEach(context)
48
49
  );
49
50
  return () => {
50
51
  cy.window({ log: false }).then(
@@ -52,16 +53,29 @@ function beforeEach(options) {
52
53
  );
53
54
  };
54
55
  }
56
+ function waitForReadiness(options) {
57
+ const context = getStabilizationContext(options);
58
+ cy.waitUntil(
59
+ () => cy.window({ log: false }).then((window) => {
60
+ const isStable = window.__ARGOS__.waitFor(
61
+ context
62
+ );
63
+ if (isStable) {
64
+ return true;
65
+ }
66
+ const failureReasons = window.__ARGOS__.getWaitFailureExplanations(context);
67
+ failureReasons.forEach((reason) => {
68
+ cy.log(`[argos] stability: ${reason}`);
69
+ });
70
+ return false;
71
+ })
72
+ );
73
+ }
55
74
  Cypress.Commands.add(
56
75
  "argosScreenshot",
57
76
  { prevSubject: ["optional", "element", "window", "document"] },
58
77
  (subject, name, options = {}) => {
59
- const {
60
- viewports,
61
- argosCSS: _argosCSS,
62
- stabilize = true,
63
- ...cypressOptions
64
- } = options;
78
+ const { viewports, argosCSS: _argosCSS, ...cypressOptions } = options;
65
79
  if (!name) {
66
80
  throw new Error("The `name` argument is required.");
67
81
  }
@@ -73,24 +87,7 @@ Cypress.Commands.add(
73
87
  injectArgos();
74
88
  const afterAll = beforeAll(options);
75
89
  function stabilizeAndScreenshot(name2) {
76
- if (stabilize) {
77
- const stabilizationOptions = typeof stabilize === "object" ? stabilize : {};
78
- cy.waitUntil(
79
- () => cy.window({ log: false }).then((window) => {
80
- const isStable = window.__ARGOS__.waitFor(
81
- stabilizationOptions
82
- );
83
- if (isStable) {
84
- return true;
85
- }
86
- const failureReasons = window.__ARGOS__.getWaitFailureExplanations(stabilizationOptions);
87
- failureReasons.forEach((reason) => {
88
- cy.log(`[argos] stability: ${reason}`);
89
- });
90
- return false;
91
- })
92
- );
93
- }
90
+ waitForReadiness(options);
94
91
  const afterEach = beforeEach(options);
95
92
  const ref = {};
96
93
  cy.wrap(subject).screenshot(name2, {
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": "3.4.0",
4
+ "version": "4.0.0",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -45,25 +45,27 @@
45
45
  "node": ">=18.0.0"
46
46
  },
47
47
  "dependencies": {
48
- "@argos-ci/browser": "3.2.0",
49
- "@argos-ci/core": "3.1.0",
50
- "@argos-ci/util": "2.3.0",
48
+ "@argos-ci/browser": "4.0.0",
49
+ "@argos-ci/core": "3.1.1",
50
+ "@argos-ci/util": "2.3.1",
51
51
  "cypress-wait-until": "^3.0.2"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "cypress": "^12.0.0 || ^13.0.0 || ^14.0.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@argos-ci/cli": "2.5.5",
58
- "@argos-ci/cypress": "workspace:.",
59
57
  "@types/node": "^18.19.44",
60
- "cypress": "^14.0.0",
61
- "eslint-plugin-cypress": "^4.1.0"
58
+ "cypress": "^14.2.0",
59
+ "eslint-plugin-cypress": "^4.2.0"
62
60
  },
63
61
  "scripts": {
64
62
  "build": "tsup",
65
- "test": "pnpm exec cypress run",
66
- "e2e": "UPLOAD_TO_ARGOS=true pnpm run test"
63
+ "test-e2e": "pnpm exec cypress run",
64
+ "build-e2e": "cypress install",
65
+ "e2e": "UPLOAD_TO_ARGOS=true pnpm run test-e2e",
66
+ "check-types": "tsc",
67
+ "check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
68
+ "lint": "eslint ."
67
69
  },
68
- "gitHead": "fae9639b570fb2cd937ce8695eed1941c25678db"
70
+ "gitHead": "6385df8f840714c9d77c52b2035bdbbc1b148791"
69
71
  }