@visual-regression-tracker/agent-cypress 5.7.0 → 5.8.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/.github/workflows/ci.yml +6 -3
- package/.github/workflows/release.yml +9 -4
- package/README.md +11 -4
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +12 -9
- package/dist/types.d.ts +2 -2
- package/dist/types.js +2 -0
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +2 -0
- package/package.json +11 -9
package/.github/workflows/ci.yml
CHANGED
|
@@ -9,15 +9,18 @@ jobs:
|
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
10
|
|
|
11
11
|
steps:
|
|
12
|
-
- uses: actions/checkout@
|
|
12
|
+
- uses: actions/checkout@v5
|
|
13
13
|
|
|
14
14
|
- name: Setup Node.js environment
|
|
15
|
-
uses: actions/setup-node@
|
|
15
|
+
uses: actions/setup-node@v5
|
|
16
16
|
with:
|
|
17
|
-
node-version:
|
|
17
|
+
node-version: 22
|
|
18
18
|
|
|
19
19
|
- name: Install npm dependencies
|
|
20
20
|
run: npm ci
|
|
21
21
|
|
|
22
22
|
- name: Build
|
|
23
23
|
run: npm run build
|
|
24
|
+
|
|
25
|
+
- name: Unit tests
|
|
26
|
+
run: npm test
|
|
@@ -7,17 +7,22 @@ jobs:
|
|
|
7
7
|
release:
|
|
8
8
|
name: Release
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
|
-
|
|
10
|
+
permissions:
|
|
11
|
+
contents: write # to publish a GitHub release
|
|
12
|
+
issues: write # to comment on released issues
|
|
13
|
+
pull-requests: write # to comment on released pull requests
|
|
14
|
+
id-token: write # to publish to npm with trusted publishing (OIDC) and provenance
|
|
15
|
+
|
|
11
16
|
steps:
|
|
12
17
|
- name: Checkout
|
|
13
|
-
uses: actions/checkout@
|
|
18
|
+
uses: actions/checkout@v5
|
|
14
19
|
with:
|
|
15
20
|
fetch-depth: 0
|
|
16
21
|
|
|
17
22
|
- name: Setup Node.js environment
|
|
18
|
-
uses: actions/setup-node@
|
|
23
|
+
uses: actions/setup-node@v5
|
|
19
24
|
with:
|
|
20
|
-
node-version:
|
|
25
|
+
node-version: 22
|
|
21
26
|
|
|
22
27
|
- name: Install dependencies
|
|
23
28
|
run: npm ci
|
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ import { addVisualRegressionTrackerPlugin } from "@visual-regression-tracker/age
|
|
|
55
55
|
export default defineConfig({
|
|
56
56
|
// e2e or component, depending of testing style
|
|
57
57
|
e2e: {
|
|
58
|
-
setupNodeEvents
|
|
58
|
+
setupNodeEvents(on, config) {
|
|
59
59
|
addVisualRegressionTrackerPlugin(on, config);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -89,9 +89,10 @@ export default defineConfig({
|
|
|
89
89
|
// Required
|
|
90
90
|
"branchName": "develop",
|
|
91
91
|
|
|
92
|
-
// Branch
|
|
92
|
+
// Branch to take baselines from instead of the project's main branch
|
|
93
93
|
// Optional - when not set, main branch from project settings is used
|
|
94
|
-
|
|
94
|
+
// Also read from VRT_SOURCEBRANCH when not set here
|
|
95
|
+
"sourceBranch": "release",
|
|
95
96
|
|
|
96
97
|
// Log errors instead of throwing exceptions
|
|
97
98
|
// Optional - default false
|
|
@@ -117,6 +118,7 @@ _Is overriden if ENV variables are present_
|
|
|
117
118
|
"apiKey": "tXZVHX0EA4YQM1MGDD",
|
|
118
119
|
"ciBuildId": "commit_sha",
|
|
119
120
|
"branchName": "develop",
|
|
121
|
+
"sourceBranch": "release",
|
|
120
122
|
"enableSoftAssert": false
|
|
121
123
|
}
|
|
122
124
|
```
|
|
@@ -131,10 +133,15 @@ VRT_PROJECT="Default project"
|
|
|
131
133
|
VRT_APIKEY="tXZVHX0EA4YQM1MGDD"
|
|
132
134
|
VRT_CIBUILDID="commit_sha"
|
|
133
135
|
VRT_BRANCHNAME="develop"
|
|
134
|
-
|
|
136
|
+
VRT_SOURCEBRANCH="release"
|
|
135
137
|
VRT_ENABLESOFTASSERT=true
|
|
136
138
|
```
|
|
137
139
|
|
|
140
|
+
`sourceBranch` replaces `baselineBranchName` (`VRT_BASELINEBRANCHNAME`), which
|
|
141
|
+
the server never read. The old name still works as an alias and logs a
|
|
142
|
+
deprecation warning; like the other `VRT_*` variables, `VRT_BASELINEBRANCHNAME`
|
|
143
|
+
is read only when `visualRegressionTracker` is not set in the Cypress config.
|
|
144
|
+
|
|
138
145
|
## Usage
|
|
139
146
|
|
|
140
147
|
### Setup
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.addVisualRegressionTrackerPlugin =
|
|
12
|
+
exports.addVisualRegressionTrackerPlugin = addVisualRegressionTrackerPlugin;
|
|
13
|
+
/// <reference types="cypress" preserve="true" />
|
|
13
14
|
const fs_1 = require("fs");
|
|
14
15
|
const sdk_js_1 = require("@visual-regression-tracker/sdk-js");
|
|
15
16
|
const utils_1 = require("./utils");
|
|
@@ -22,42 +23,45 @@ const utils_1 = require("./utils");
|
|
|
22
23
|
function addVisualRegressionTrackerPlugin(on, config) {
|
|
23
24
|
var _a;
|
|
24
25
|
const vrtConfig = (_a = config === null || config === void 0 ? void 0 : config.env) === null || _a === void 0 ? void 0 : _a.visualRegressionTracker;
|
|
25
|
-
|
|
26
|
+
// sdk-js skips VRT_* variables when given an explicit config
|
|
27
|
+
const vrt = new sdk_js_1.VisualRegressionTracker(vrtConfig && Object.assign(Object.assign({}, vrtConfig), { sourceBranch: vrtConfig.sourceBranch ||
|
|
28
|
+
vrtConfig.baselineBranchName ||
|
|
29
|
+
process.env.VRT_SOURCEBRANCH }));
|
|
26
30
|
on("task", {
|
|
27
31
|
// Start visual regression tracking unless it has already been started
|
|
28
32
|
[utils_1.VRT_TASK_START]: (props) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
var
|
|
33
|
+
var _a;
|
|
30
34
|
try {
|
|
31
35
|
if (!vrt[utils_1.VRT_IS_STARTED]()) {
|
|
32
36
|
yield vrt.start();
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
catch (err) {
|
|
36
|
-
return (
|
|
40
|
+
return (_a = err.message) !== null && _a !== void 0 ? _a : err;
|
|
37
41
|
}
|
|
38
42
|
return null;
|
|
39
43
|
}),
|
|
40
44
|
// Stop visual regression tracking if it was started
|
|
41
45
|
[utils_1.VRT_TASK_STOP]: (props) => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
var
|
|
46
|
+
var _a;
|
|
43
47
|
try {
|
|
44
48
|
if (vrt[utils_1.VRT_IS_STARTED]()) {
|
|
45
49
|
yield vrt.stop();
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
catch (err) {
|
|
49
|
-
return (
|
|
53
|
+
return (_a = err.message) !== null && _a !== void 0 ? _a : err;
|
|
50
54
|
}
|
|
51
55
|
return null;
|
|
52
56
|
}),
|
|
53
57
|
// Track the given test case and optionally clean up the screenshot
|
|
54
58
|
[utils_1.VRT_TASK_TRACK]: (props) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
var
|
|
59
|
+
var _a;
|
|
56
60
|
try {
|
|
57
61
|
return yield vrt.track(props, props === null || props === void 0 ? void 0 : props.retryLimit);
|
|
58
62
|
}
|
|
59
63
|
catch (err) {
|
|
60
|
-
return (
|
|
64
|
+
return (_a = err.message) !== null && _a !== void 0 ? _a : err;
|
|
61
65
|
}
|
|
62
66
|
finally {
|
|
63
67
|
if (!props.keepScreenshot && props.imagePath) {
|
|
@@ -67,4 +71,3 @@ function addVisualRegressionTrackerPlugin(on, config) {
|
|
|
67
71
|
}),
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
|
-
exports.addVisualRegressionTrackerPlugin = addVisualRegressionTrackerPlugin;
|
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="cypress" />
|
|
2
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="cypress" preserve="true" />
|
|
2
|
+
/// <reference types="node" preserve="true" />
|
|
3
3
|
import { TestRunResponse } from "@visual-regression-tracker/sdk-js";
|
|
4
4
|
export declare const VRT_TASK_START = "VRT_START";
|
|
5
5
|
export declare const VRT_TASK_STOP = "VRT_STOP";
|
|
@@ -14,7 +14,7 @@ export declare const log: (message: string) => Cypress.Log;
|
|
|
14
14
|
export declare const handleError: (err: unknown) => void;
|
|
15
15
|
export declare const toTestRunDto: ({ name, pixelRatio, options, }: {
|
|
16
16
|
name: string;
|
|
17
|
-
pixelRatio?: number
|
|
17
|
+
pixelRatio?: number;
|
|
18
18
|
options: any;
|
|
19
19
|
}) => {
|
|
20
20
|
name: string;
|
|
@@ -28,7 +28,7 @@ export declare const toTestRunDto: ({ name, pixelRatio, options, }: {
|
|
|
28
28
|
keepScreenshot: any;
|
|
29
29
|
retryLimit: any;
|
|
30
30
|
};
|
|
31
|
-
export declare const checkResult: (result: TestRunResponse | string, errorCallback?: (
|
|
31
|
+
export declare const checkResult: (result: TestRunResponse | string, errorCallback?: (err: string) => boolean) => void;
|
|
32
32
|
export declare const trackImage: (subject: any, name: string, options: any) => Cypress.Chainable<TestRunResponse>;
|
|
33
33
|
export declare const trackBuffer: (name: string, imageBuffer: Buffer, options: any) => Cypress.Chainable<TestRunResponse>;
|
|
34
34
|
export declare const trackBase64: (name: string, imageBase64: string, options: any) => Cypress.Chainable<TestRunResponse>;
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/// <reference types="cypress" preserve="true" />
|
|
3
|
+
/// <reference types="node" preserve="true" />
|
|
2
4
|
/* global Cypress, cy */
|
|
3
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
6
|
exports.trackBase64 = exports.trackBuffer = exports.trackImage = exports.checkResult = exports.toTestRunDto = exports.handleError = exports.log = exports.VRT_IS_STARTED = exports.VRT_COMMAND_TRACK_BASE64 = exports.VRT_COMMAND_TRACK_BUFFER = exports.VRT_COMMAND_TRACK = exports.VRT_COMMAND_STOP = exports.VRT_COMMAND_START = exports.VRT_TASK_TRACK = exports.VRT_TASK_STOP = exports.VRT_TASK_START = void 0;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visual-regression-tracker/agent-cypress",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "Visual Regression Tracker integration plugin for Cypress",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
+
"test": "jest",
|
|
9
10
|
"semantic-release": "semantic-release"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|
|
@@ -27,16 +28,17 @@
|
|
|
27
28
|
"node": ">=16.16.0"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@visual-regression-tracker/sdk-js": "5.
|
|
31
|
+
"@visual-regression-tracker/sdk-js": "^5.8.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@types/
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
34
|
+
"@jest/globals": "^30.5.2",
|
|
35
|
+
"@types/jest": "^30.0.0",
|
|
36
|
+
"@types/node": "^22.20.5",
|
|
37
|
+
"cypress": "^16.2.0",
|
|
38
|
+
"jest": "^30.5.2",
|
|
39
|
+
"semantic-release": "^25.0.9",
|
|
40
|
+
"ts-jest": "^29.4.15",
|
|
41
|
+
"typescript": "^6.0.3"
|
|
40
42
|
},
|
|
41
43
|
"peerDependencies": {
|
|
42
44
|
"cypress": ">=12.17.1"
|