@argos-ci/cypress 1.1.2 → 1.2.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 +7 -0
- package/dist/support.mjs +29 -18
- package/package.json +3 -3
package/dist/support.d.ts
CHANGED
|
@@ -11,7 +11,14 @@ declare global {
|
|
|
11
11
|
* cy.get(".post").argosScreenshot()
|
|
12
12
|
*/
|
|
13
13
|
argosScreenshot: (name: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions> & {
|
|
14
|
+
/**
|
|
15
|
+
* Viewports to take screenshots of.
|
|
16
|
+
*/
|
|
14
17
|
viewports?: ViewportOption[];
|
|
18
|
+
/**
|
|
19
|
+
* Custom CSS evaluated during the screenshot process.
|
|
20
|
+
*/
|
|
21
|
+
argosCSS?: string;
|
|
15
22
|
}) => Chainable<null>;
|
|
16
23
|
}
|
|
17
24
|
}
|
package/dist/support.mjs
CHANGED
|
@@ -3,12 +3,15 @@ import { resolveViewport } from '@argos-ci/browser';
|
|
|
3
3
|
import { getScreenshotName, getMetadataPath } from '@argos-ci/util/browser';
|
|
4
4
|
|
|
5
5
|
function injectArgos() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
cy.window({
|
|
7
|
+
log: false
|
|
8
|
+
}).then((window)=>{
|
|
9
|
+
if (typeof window.__ARGOS__ !== "undefined") return;
|
|
10
|
+
const fileName = typeof require.resolve === "function" ? require.resolve("@argos-ci/browser/global.js") : "node_modules/@argos-ci/browser/dist/global.js";
|
|
11
|
+
return cy.readFile(fileName).then((source)=>{
|
|
10
12
|
window.eval(source);
|
|
11
|
-
})
|
|
13
|
+
});
|
|
14
|
+
});
|
|
12
15
|
}
|
|
13
16
|
function readArgosCypressVersion() {
|
|
14
17
|
const fileName = typeof require.resolve === "function" ? require.resolve("@argos-ci/cypress/package.json") : "node_modules/@argos-ci/cypress/package.json";
|
|
@@ -23,7 +26,7 @@ Cypress.Commands.add("argosScreenshot", {
|
|
|
23
26
|
"window",
|
|
24
27
|
"document"
|
|
25
28
|
]
|
|
26
|
-
}, (subject, name, { viewports, ...options } = {})=>{
|
|
29
|
+
}, (subject, name, { viewports, argosCSS, ...options } = {})=>{
|
|
27
30
|
if (!name) {
|
|
28
31
|
throw new Error("The `name` argument is required.");
|
|
29
32
|
}
|
|
@@ -36,8 +39,9 @@ Cypress.Commands.add("argosScreenshot", {
|
|
|
36
39
|
const fullPage = !options.capture || options.capture === "fullPage";
|
|
37
40
|
cy.window({
|
|
38
41
|
log: false
|
|
39
|
-
}).then((window)=>window.__ARGOS__.
|
|
40
|
-
fullPage
|
|
42
|
+
}).then((window)=>window.__ARGOS__.setup({
|
|
43
|
+
fullPage,
|
|
44
|
+
argosCSS
|
|
41
45
|
}));
|
|
42
46
|
function stabilizeAndScreenshot(name) {
|
|
43
47
|
cy.waitUntil(()=>cy.window({
|
|
@@ -88,17 +92,24 @@ Cypress.Commands.add("argosScreenshot", {
|
|
|
88
92
|
});
|
|
89
93
|
});
|
|
90
94
|
}
|
|
91
|
-
if (
|
|
95
|
+
if (viewports) {
|
|
96
|
+
for (const viewport of viewports){
|
|
97
|
+
const viewportSize = resolveViewport(viewport);
|
|
98
|
+
cy.viewport(viewportSize.width, viewportSize.height);
|
|
99
|
+
stabilizeAndScreenshot(getScreenshotName(name, {
|
|
100
|
+
viewportWidth: viewportSize.width
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
// Restore the original viewport
|
|
104
|
+
cy.viewport(Cypress.config("viewportWidth"), Cypress.config("viewportHeight"));
|
|
105
|
+
} else {
|
|
92
106
|
stabilizeAndScreenshot(name);
|
|
93
|
-
return;
|
|
94
107
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
// Teardown Argos
|
|
109
|
+
cy.window({
|
|
110
|
+
log: false
|
|
111
|
+
}).then((window)=>window.__ARGOS__.teardown({
|
|
112
|
+
fullPage,
|
|
113
|
+
argosCSS
|
|
100
114
|
}));
|
|
101
|
-
}
|
|
102
|
-
// Restore the original viewport
|
|
103
|
-
cy.viewport(Cypress.config("viewportWidth"), Cypress.config("viewportHeight"));
|
|
104
115
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/cypress",
|
|
3
3
|
"description": "Visual testing solution to avoid visual regression. Cypress commands and utilities for Argos visual testing.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"node": ">=16.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@argos-ci/browser": "1.
|
|
39
|
+
"@argos-ci/browser": "1.2.0",
|
|
40
40
|
"@argos-ci/util": "1.1.0",
|
|
41
41
|
"cypress-wait-until": "^1.7.2"
|
|
42
42
|
},
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"argos-upload": "pnpm exec argos upload cypress/screenshots --build-name \"argos-cypress-e2e-node-$NODE_VERSION-$OS\"",
|
|
59
59
|
"e2e": "pnpm run test && pnpm run argos-upload"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "ad3ddc6e774f2b6e381259b4bfae72855326246b"
|
|
62
62
|
}
|