@argos-ci/cypress 1.3.4 → 1.5.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 +11 -10
- package/dist/support.mjs +30 -24
- package/dist/task.cjs +15 -0
- package/dist/task.mjs +15 -0
- package/package.json +5 -5
package/dist/support.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { ViewportOption } from "@argos-ci/browser";
|
|
2
|
+
type ArgosScreenshotOptions = Partial<Cypress.Loggable & Cypress.Timeoutable & Cypress.ScreenshotOptions> & {
|
|
3
|
+
/**
|
|
4
|
+
* Viewports to take screenshots of.
|
|
5
|
+
*/
|
|
6
|
+
viewports?: ViewportOption[];
|
|
7
|
+
/**
|
|
8
|
+
* Custom CSS evaluated during the screenshot process.
|
|
9
|
+
*/
|
|
10
|
+
argosCSS?: string;
|
|
11
|
+
};
|
|
2
12
|
declare global {
|
|
3
13
|
namespace Cypress {
|
|
4
14
|
interface Chainable {
|
|
@@ -10,16 +20,7 @@ declare global {
|
|
|
10
20
|
* cy.argosScreenshot("my-screenshot")
|
|
11
21
|
* cy.get(".post").argosScreenshot()
|
|
12
22
|
*/
|
|
13
|
-
argosScreenshot: (name: string, options?:
|
|
14
|
-
/**
|
|
15
|
-
* Viewports to take screenshots of.
|
|
16
|
-
*/
|
|
17
|
-
viewports?: ViewportOption[];
|
|
18
|
-
/**
|
|
19
|
-
* Custom CSS evaluated during the screenshot process.
|
|
20
|
-
*/
|
|
21
|
-
argosCSS?: string;
|
|
22
|
-
}) => Chainable<null>;
|
|
23
|
+
argosScreenshot: (name: string, options?: ArgosScreenshotOptions) => Chainable<null>;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
}
|
package/dist/support.mjs
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import 'cypress-wait-until';
|
|
2
|
-
import { resolveViewport } from '@argos-ci/browser';
|
|
3
|
-
import { getGlobalFilePath } from '@argos-ci/browser/cypress.cjs';
|
|
2
|
+
import { resolveViewport, getGlobalScript } from '@argos-ci/browser';
|
|
4
3
|
import { getScreenshotName, getMetadataPath } from '@argos-ci/util/browser';
|
|
5
4
|
|
|
6
|
-
var version = "1.
|
|
5
|
+
var version = "1.4.0";
|
|
7
6
|
|
|
8
7
|
function injectArgos() {
|
|
9
8
|
cy.window({
|
|
10
9
|
log: false
|
|
11
10
|
}).then((window)=>{
|
|
12
11
|
if (typeof window.__ARGOS__ !== "undefined") return;
|
|
13
|
-
|
|
14
|
-
return cy.readFile(fileName).then((source)=>{
|
|
15
|
-
window.eval(source);
|
|
16
|
-
});
|
|
12
|
+
window.eval(getGlobalScript());
|
|
17
13
|
});
|
|
18
14
|
}
|
|
15
|
+
function setup(options) {
|
|
16
|
+
const { argosCSS } = options;
|
|
17
|
+
const fullPage = !options.capture || options.capture === "fullPage";
|
|
18
|
+
cy.window({
|
|
19
|
+
log: false
|
|
20
|
+
}).then((window)=>window.__ARGOS__.setup({
|
|
21
|
+
fullPage,
|
|
22
|
+
argosCSS
|
|
23
|
+
}));
|
|
24
|
+
return ()=>{
|
|
25
|
+
cy.window({
|
|
26
|
+
log: false
|
|
27
|
+
}).then((window)=>window.__ARGOS__.teardown({
|
|
28
|
+
fullPage,
|
|
29
|
+
argosCSS
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
19
33
|
Cypress.Commands.add("argosScreenshot", {
|
|
20
34
|
prevSubject: [
|
|
21
35
|
"optional",
|
|
@@ -23,7 +37,8 @@ Cypress.Commands.add("argosScreenshot", {
|
|
|
23
37
|
"window",
|
|
24
38
|
"document"
|
|
25
39
|
]
|
|
26
|
-
}, (subject, name,
|
|
40
|
+
}, (subject, name, options = {})=>{
|
|
41
|
+
const { viewports, argosCSS, ...cypressOptions } = options;
|
|
27
42
|
if (!name) {
|
|
28
43
|
throw new Error("The `name` argument is required.");
|
|
29
44
|
}
|
|
@@ -33,13 +48,7 @@ Cypress.Commands.add("argosScreenshot", {
|
|
|
33
48
|
message: name
|
|
34
49
|
});
|
|
35
50
|
injectArgos();
|
|
36
|
-
const
|
|
37
|
-
cy.window({
|
|
38
|
-
log: false
|
|
39
|
-
}).then((window)=>window.__ARGOS__.setup({
|
|
40
|
-
fullPage,
|
|
41
|
-
argosCSS
|
|
42
|
-
}));
|
|
51
|
+
const teardown = setup(options);
|
|
43
52
|
function stabilizeAndScreenshot(name) {
|
|
44
53
|
cy.waitUntil(()=>cy.window({
|
|
45
54
|
log: false
|
|
@@ -52,7 +61,7 @@ Cypress.Commands.add("argosScreenshot", {
|
|
|
52
61
|
onAfterScreenshot: (_$el, props)=>{
|
|
53
62
|
ref.props = props;
|
|
54
63
|
},
|
|
55
|
-
...
|
|
64
|
+
...cypressOptions
|
|
56
65
|
});
|
|
57
66
|
cy.window({
|
|
58
67
|
log: false
|
|
@@ -69,7 +78,10 @@ Cypress.Commands.add("argosScreenshot", {
|
|
|
69
78
|
mediaType,
|
|
70
79
|
test: {
|
|
71
80
|
title: Cypress.currentTest.title,
|
|
72
|
-
titlePath: Cypress.currentTest.titlePath
|
|
81
|
+
titlePath: Cypress.currentTest.titlePath,
|
|
82
|
+
retry: Cypress.currentRetry,
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
retries: cy.state("runnable")._retries
|
|
73
85
|
},
|
|
74
86
|
browser: {
|
|
75
87
|
name: Cypress.browser.name,
|
|
@@ -100,11 +112,5 @@ Cypress.Commands.add("argosScreenshot", {
|
|
|
100
112
|
} else {
|
|
101
113
|
stabilizeAndScreenshot(name);
|
|
102
114
|
}
|
|
103
|
-
|
|
104
|
-
cy.window({
|
|
105
|
-
log: false
|
|
106
|
-
}).then((window)=>window.__ARGOS__.teardown({
|
|
107
|
-
fullPage,
|
|
108
|
-
argosCSS
|
|
109
|
-
}));
|
|
115
|
+
teardown();
|
|
110
116
|
});
|
package/dist/task.cjs
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@argos-ci/core');
|
|
4
|
+
var node_path = require('node:path');
|
|
5
|
+
var promises = require('node:fs/promises');
|
|
4
6
|
|
|
5
7
|
/// <reference types="cypress" />
|
|
6
8
|
function registerArgosTask(on, config, options) {
|
|
9
|
+
on("after:screenshot", async (details)=>{
|
|
10
|
+
// Get the base filename without extension
|
|
11
|
+
const baseName = node_path.basename(details.path, node_path.extname(details.path));
|
|
12
|
+
// Remove attempt from the filename
|
|
13
|
+
const newBaseName = baseName.replace(/ \(attempt \d+\)/, "");
|
|
14
|
+
// Construct a new path with the original file extension
|
|
15
|
+
const newPath = node_path.join(node_path.dirname(details.path), newBaseName + node_path.extname(details.path));
|
|
16
|
+
// Rename the file
|
|
17
|
+
await promises.rename(details.path, newPath);
|
|
18
|
+
return {
|
|
19
|
+
path: newPath
|
|
20
|
+
};
|
|
21
|
+
});
|
|
7
22
|
on("after:run", async ()=>{
|
|
8
23
|
const { screenshotsFolder } = config;
|
|
9
24
|
if (!screenshotsFolder) return;
|
package/dist/task.mjs
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import { upload } from '@argos-ci/core';
|
|
2
|
+
import { basename, extname, join, dirname } from 'node:path';
|
|
3
|
+
import { rename } from 'node:fs/promises';
|
|
2
4
|
|
|
3
5
|
/// <reference types="cypress" />
|
|
4
6
|
function registerArgosTask(on, config, options) {
|
|
7
|
+
on("after:screenshot", async (details)=>{
|
|
8
|
+
// Get the base filename without extension
|
|
9
|
+
const baseName = basename(details.path, extname(details.path));
|
|
10
|
+
// Remove attempt from the filename
|
|
11
|
+
const newBaseName = baseName.replace(/ \(attempt \d+\)/, "");
|
|
12
|
+
// Construct a new path with the original file extension
|
|
13
|
+
const newPath = join(dirname(details.path), newBaseName + extname(details.path));
|
|
14
|
+
// Rename the file
|
|
15
|
+
await rename(details.path, newPath);
|
|
16
|
+
return {
|
|
17
|
+
path: newPath
|
|
18
|
+
};
|
|
19
|
+
});
|
|
5
20
|
on("after:run", async ()=>{
|
|
6
21
|
const { screenshotsFolder } = config;
|
|
7
22
|
if (!screenshotsFolder) return;
|
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.5.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"node": ">=16.0.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@argos-ci/browser": "1.
|
|
46
|
-
"@argos-ci/core": "1.5.
|
|
45
|
+
"@argos-ci/browser": "1.4.1",
|
|
46
|
+
"@argos-ci/core": "1.5.2",
|
|
47
47
|
"@argos-ci/util": "1.2.0",
|
|
48
48
|
"cypress-wait-until": "^1.7.2"
|
|
49
49
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"cypress": "^12.0.0 || ^13.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@argos-ci/cli": "1.0.
|
|
54
|
+
"@argos-ci/cli": "1.0.9",
|
|
55
55
|
"@argos-ci/cypress": "workspace:.",
|
|
56
56
|
"@types/node": "^16.0.0",
|
|
57
57
|
"cypress": "^13.3.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"test": "pnpm exec cypress run",
|
|
65
65
|
"e2e": "UPLOAD_TO_ARGOS=true pnpm run test"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "47e813466b9224cb428eb44ee4d4d450f737763e"
|
|
68
68
|
}
|