@argos-ci/cypress 3.3.3 → 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 +2 -2
- package/dist/support.js +47 -34
- package/package.json +13 -11
package/dist/support.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ViewportOption,
|
|
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 |
|
|
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.
|
|
14
|
+
var version = "3.4.0";
|
|
15
15
|
|
|
16
16
|
// src/support.ts
|
|
17
17
|
function injectArgos() {
|
|
@@ -22,31 +22,60 @@ function injectArgos() {
|
|
|
22
22
|
window.eval(getGlobalScript());
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
function
|
|
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);
|
|
36
|
+
cy.window({ log: false }).then(
|
|
37
|
+
(window) => window.__ARGOS__.beforeAll(context)
|
|
38
|
+
);
|
|
39
|
+
return () => {
|
|
40
|
+
cy.window({ log: false }).then(
|
|
41
|
+
(window) => window.__ARGOS__.afterAll()
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function beforeEach(options) {
|
|
46
|
+
const context = getStabilizationContext(options);
|
|
28
47
|
cy.window({ log: false }).then(
|
|
29
|
-
(window) => window.__ARGOS__.
|
|
48
|
+
(window) => window.__ARGOS__.beforeEach(context)
|
|
30
49
|
);
|
|
31
50
|
return () => {
|
|
32
51
|
cy.window({ log: false }).then(
|
|
33
|
-
(window) => window.__ARGOS__.
|
|
34
|
-
fullPage,
|
|
35
|
-
argosCSS
|
|
36
|
-
})
|
|
52
|
+
(window) => window.__ARGOS__.afterEach()
|
|
37
53
|
);
|
|
38
54
|
};
|
|
39
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
|
+
}
|
|
40
74
|
Cypress.Commands.add(
|
|
41
75
|
"argosScreenshot",
|
|
42
76
|
{ prevSubject: ["optional", "element", "window", "document"] },
|
|
43
77
|
(subject, name, options = {}) => {
|
|
44
|
-
const {
|
|
45
|
-
viewports,
|
|
46
|
-
argosCSS: _argosCSS,
|
|
47
|
-
stabilize = true,
|
|
48
|
-
...cypressOptions
|
|
49
|
-
} = options;
|
|
78
|
+
const { viewports, argosCSS: _argosCSS, ...cypressOptions } = options;
|
|
50
79
|
if (!name) {
|
|
51
80
|
throw new Error("The `name` argument is required.");
|
|
52
81
|
}
|
|
@@ -56,24 +85,10 @@ Cypress.Commands.add(
|
|
|
56
85
|
message: name
|
|
57
86
|
});
|
|
58
87
|
injectArgos();
|
|
59
|
-
const
|
|
88
|
+
const afterAll = beforeAll(options);
|
|
60
89
|
function stabilizeAndScreenshot(name2) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
cy.waitUntil(
|
|
64
|
-
() => cy.window({ log: false }).then((window) => {
|
|
65
|
-
const isStable = window.__ARGOS__.checkIsStable(stabilizationOptions);
|
|
66
|
-
if (isStable) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
const failureReasons = window.__ARGOS__.getStabilityFailureReasons(stabilizationOptions);
|
|
70
|
-
failureReasons.forEach((reason) => {
|
|
71
|
-
cy.log(`[argos] stability: ${reason}`);
|
|
72
|
-
});
|
|
73
|
-
return false;
|
|
74
|
-
})
|
|
75
|
-
);
|
|
76
|
-
}
|
|
90
|
+
waitForReadiness(options);
|
|
91
|
+
const afterEach = beforeEach(options);
|
|
77
92
|
const ref = {};
|
|
78
93
|
cy.wrap(subject).screenshot(name2, {
|
|
79
94
|
blackout: ['[data-visual-test="blackout"]'].concat(
|
|
@@ -122,9 +137,7 @@ Cypress.Commands.add(
|
|
|
122
137
|
}
|
|
123
138
|
cy.writeFile(getMetadataPath(ref.props.path), JSON.stringify(metadata));
|
|
124
139
|
});
|
|
125
|
-
|
|
126
|
-
window.__ARGOS__.afterEach();
|
|
127
|
-
});
|
|
140
|
+
afterEach();
|
|
128
141
|
}
|
|
129
142
|
if (viewports) {
|
|
130
143
|
for (const viewport of viewports) {
|
|
@@ -141,6 +154,6 @@ Cypress.Commands.add(
|
|
|
141
154
|
} else {
|
|
142
155
|
stabilizeAndScreenshot(name);
|
|
143
156
|
}
|
|
144
|
-
|
|
157
|
+
afterAll();
|
|
145
158
|
}
|
|
146
159
|
);
|
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": "
|
|
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": "
|
|
49
|
-
"@argos-ci/core": "3.1.
|
|
50
|
-
"@argos-ci/util": "2.3.
|
|
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.
|
|
61
|
-
"eslint-plugin-cypress": "^4.
|
|
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": "
|
|
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": "
|
|
70
|
+
"gitHead": "6385df8f840714c9d77c52b2035bdbbc1b148791"
|
|
69
71
|
}
|