@argos-ci/cypress 4.0.5 → 5.0.1
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.js +5 -2
- package/dist/task.cjs +59 -11
- package/dist/task.js +50 -12
- package/package.json +4 -4
package/dist/support.js
CHANGED
|
@@ -11,7 +11,10 @@ import {
|
|
|
11
11
|
} from "@argos-ci/util/browser";
|
|
12
12
|
|
|
13
13
|
// package.json
|
|
14
|
-
var version = "
|
|
14
|
+
var version = "5.0.0";
|
|
15
|
+
|
|
16
|
+
// src/shared.ts
|
|
17
|
+
var NAME_PREFIX = "argos/";
|
|
15
18
|
|
|
16
19
|
// src/support.ts
|
|
17
20
|
function injectArgos() {
|
|
@@ -90,7 +93,7 @@ Cypress.Commands.add(
|
|
|
90
93
|
waitForReadiness(options);
|
|
91
94
|
const afterEach = beforeEach(options);
|
|
92
95
|
const ref = {};
|
|
93
|
-
cy.wrap(subject).screenshot(name2
|
|
96
|
+
cy.wrap(subject).screenshot(`${NAME_PREFIX}${name2}`, {
|
|
94
97
|
blackout: ['[data-visual-test="blackout"]'].concat(
|
|
95
98
|
options.blackout || []
|
|
96
99
|
),
|
package/dist/task.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/task.ts
|
|
@@ -25,34 +35,72 @@ __export(task_exports, {
|
|
|
25
35
|
module.exports = __toCommonJS(task_exports);
|
|
26
36
|
var import_core = require("@argos-ci/core");
|
|
27
37
|
var import_node_path = require("path");
|
|
38
|
+
|
|
39
|
+
// src/shared.ts
|
|
40
|
+
var NAME_PREFIX = "argos/";
|
|
41
|
+
|
|
42
|
+
// src/task.ts
|
|
28
43
|
var import_promises = require("fs/promises");
|
|
29
44
|
function checkIsCypressFailedResult(results) {
|
|
30
45
|
return "status" in results && results.status === "failed";
|
|
31
46
|
}
|
|
47
|
+
var screenshotsDirectoryPromise = void 0;
|
|
48
|
+
async function getScreenshotsDirectory() {
|
|
49
|
+
const { createTemporaryDirectory } = await import("@argos-ci/util");
|
|
50
|
+
if (!screenshotsDirectoryPromise) {
|
|
51
|
+
screenshotsDirectoryPromise = createTemporaryDirectory();
|
|
52
|
+
}
|
|
53
|
+
return screenshotsDirectoryPromise;
|
|
54
|
+
}
|
|
55
|
+
async function createDirectory(directory) {
|
|
56
|
+
const { createDirectory: createDirectory2 } = await import("@argos-ci/util");
|
|
57
|
+
await createDirectory2(directory);
|
|
58
|
+
}
|
|
32
59
|
function registerArgosTask(on, config, options) {
|
|
33
60
|
on("after:screenshot", async (details) => {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
61
|
+
const { uploadToArgos = true } = options || {};
|
|
62
|
+
if (!uploadToArgos) {
|
|
63
|
+
return { path: details.path };
|
|
64
|
+
}
|
|
65
|
+
const argosScreenshotsDir = await getScreenshotsDirectory();
|
|
66
|
+
if (details.name?.startsWith(NAME_PREFIX)) {
|
|
67
|
+
const newPath2 = (0, import_node_path.join)(
|
|
68
|
+
argosScreenshotsDir,
|
|
69
|
+
details.name.slice(NAME_PREFIX.length) + (0, import_node_path.extname)(details.path)
|
|
70
|
+
);
|
|
71
|
+
await createDirectory((0, import_node_path.dirname)(newPath2));
|
|
72
|
+
await (0, import_promises.rename)(details.path, newPath2);
|
|
73
|
+
return { path: newPath2 };
|
|
74
|
+
}
|
|
75
|
+
const { screenshotsFolder } = config;
|
|
76
|
+
if (!screenshotsFolder) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
"Cypress screenshotsFolder is not defined. Please set it in your cypress.config.js"
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (!details.path.startsWith(screenshotsFolder)) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Cypress screenshot path ${details.path} does not start with the configured screenshotsFolder ${screenshotsFolder}. Please check your cypress.config.js.`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
const relativePath = details.path.slice(
|
|
87
|
+
screenshotsFolder.length + (screenshotsFolder.endsWith("/") ? 0 : 1)
|
|
39
88
|
);
|
|
89
|
+
const newPath = (0, import_node_path.join)(argosScreenshotsDir, relativePath);
|
|
90
|
+
await createDirectory((0, import_node_path.dirname)(newPath));
|
|
40
91
|
await (0, import_promises.rename)(details.path, newPath);
|
|
41
|
-
return { path:
|
|
92
|
+
return { path: (0, import_node_path.join)(argosScreenshotsDir, relativePath) };
|
|
42
93
|
});
|
|
43
94
|
on("after:run", async (results) => {
|
|
44
|
-
const { screenshotsFolder } = config;
|
|
45
|
-
if (!screenshotsFolder) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
95
|
const { uploadToArgos = true } = options || {};
|
|
49
96
|
if (!uploadToArgos) {
|
|
50
97
|
return;
|
|
51
98
|
}
|
|
99
|
+
const argosScreenshotsDir = await getScreenshotsDirectory();
|
|
52
100
|
const res = await (0, import_core.upload)({
|
|
53
101
|
...options,
|
|
54
102
|
files: ["**/*.png"],
|
|
55
|
-
root:
|
|
103
|
+
root: argosScreenshotsDir,
|
|
56
104
|
metadata: {
|
|
57
105
|
testReport: checkIsCypressFailedResult(results) ? { status: "failed" } : {
|
|
58
106
|
status: "passed",
|
package/dist/task.js
CHANGED
|
@@ -1,34 +1,72 @@
|
|
|
1
1
|
// src/task.ts
|
|
2
2
|
import { upload } from "@argos-ci/core";
|
|
3
|
-
import {
|
|
3
|
+
import { extname, join, dirname } from "node:path";
|
|
4
|
+
|
|
5
|
+
// src/shared.ts
|
|
6
|
+
var NAME_PREFIX = "argos/";
|
|
7
|
+
|
|
8
|
+
// src/task.ts
|
|
4
9
|
import { rename } from "node:fs/promises";
|
|
5
10
|
function checkIsCypressFailedResult(results) {
|
|
6
11
|
return "status" in results && results.status === "failed";
|
|
7
12
|
}
|
|
13
|
+
var screenshotsDirectoryPromise = void 0;
|
|
14
|
+
async function getScreenshotsDirectory() {
|
|
15
|
+
const { createTemporaryDirectory } = await import("@argos-ci/util");
|
|
16
|
+
if (!screenshotsDirectoryPromise) {
|
|
17
|
+
screenshotsDirectoryPromise = createTemporaryDirectory();
|
|
18
|
+
}
|
|
19
|
+
return screenshotsDirectoryPromise;
|
|
20
|
+
}
|
|
21
|
+
async function createDirectory(directory) {
|
|
22
|
+
const { createDirectory: createDirectory2 } = await import("@argos-ci/util");
|
|
23
|
+
await createDirectory2(directory);
|
|
24
|
+
}
|
|
8
25
|
function registerArgosTask(on, config, options) {
|
|
9
26
|
on("after:screenshot", async (details) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
const { uploadToArgos = true } = options || {};
|
|
28
|
+
if (!uploadToArgos) {
|
|
29
|
+
return { path: details.path };
|
|
30
|
+
}
|
|
31
|
+
const argosScreenshotsDir = await getScreenshotsDirectory();
|
|
32
|
+
if (details.name?.startsWith(NAME_PREFIX)) {
|
|
33
|
+
const newPath2 = join(
|
|
34
|
+
argosScreenshotsDir,
|
|
35
|
+
details.name.slice(NAME_PREFIX.length) + extname(details.path)
|
|
36
|
+
);
|
|
37
|
+
await createDirectory(dirname(newPath2));
|
|
38
|
+
await rename(details.path, newPath2);
|
|
39
|
+
return { path: newPath2 };
|
|
40
|
+
}
|
|
41
|
+
const { screenshotsFolder } = config;
|
|
42
|
+
if (!screenshotsFolder) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
"Cypress screenshotsFolder is not defined. Please set it in your cypress.config.js"
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (!details.path.startsWith(screenshotsFolder)) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Cypress screenshot path ${details.path} does not start with the configured screenshotsFolder ${screenshotsFolder}. Please check your cypress.config.js.`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
const relativePath = details.path.slice(
|
|
53
|
+
screenshotsFolder.length + (screenshotsFolder.endsWith("/") ? 0 : 1)
|
|
15
54
|
);
|
|
55
|
+
const newPath = join(argosScreenshotsDir, relativePath);
|
|
56
|
+
await createDirectory(dirname(newPath));
|
|
16
57
|
await rename(details.path, newPath);
|
|
17
|
-
return { path:
|
|
58
|
+
return { path: join(argosScreenshotsDir, relativePath) };
|
|
18
59
|
});
|
|
19
60
|
on("after:run", async (results) => {
|
|
20
|
-
const { screenshotsFolder } = config;
|
|
21
|
-
if (!screenshotsFolder) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
61
|
const { uploadToArgos = true } = options || {};
|
|
25
62
|
if (!uploadToArgos) {
|
|
26
63
|
return;
|
|
27
64
|
}
|
|
65
|
+
const argosScreenshotsDir = await getScreenshotsDirectory();
|
|
28
66
|
const res = await upload({
|
|
29
67
|
...options,
|
|
30
68
|
files: ["**/*.png"],
|
|
31
|
-
root:
|
|
69
|
+
root: argosScreenshotsDir,
|
|
32
70
|
metadata: {
|
|
33
71
|
testReport: checkIsCypressFailedResult(results) ? { status: "failed" } : {
|
|
34
72
|
status: "passed",
|
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": "5.0.1",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@argos-ci/browser": "4.1.2",
|
|
49
|
-
"@argos-ci/core": "3.2.
|
|
50
|
-
"@argos-ci/util": "2.3.
|
|
49
|
+
"@argos-ci/core": "3.2.1",
|
|
50
|
+
"@argos-ci/util": "2.3.2",
|
|
51
51
|
"cypress-wait-until": "^3.0.2"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
|
|
68
68
|
"lint": "eslint ."
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "1504eec02534235dc749f470150c37fc3beac1c0"
|
|
71
71
|
}
|