@visual-regression-tracker/agent-cypress 5.0.1 → 5.3.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/release.yml +1 -1
- package/README.md +5 -0
- package/dist/commands.d.ts +2 -0
- package/dist/commands.js +21 -1
- package/dist/index.d.ts +5 -0
- package/dist/plugin.js +39 -13
- package/dist/utils.d.ts +6 -2
- package/dist/utils.js +16 -5
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -19,11 +19,15 @@ import {
|
|
|
19
19
|
addVrtTrackCommand,
|
|
20
20
|
addVrtStartCommand,
|
|
21
21
|
addVrtStopCommand,
|
|
22
|
+
addVrtTrackBufferCommand,
|
|
23
|
+
addVrtTrackBase64Command,
|
|
22
24
|
} from "@visual-regression-tracker/agent-cypress/dist/commands";
|
|
23
25
|
|
|
24
26
|
addVrtStartCommand();
|
|
25
27
|
addVrtStopCommand();
|
|
26
28
|
addVrtTrackCommand();
|
|
29
|
+
addVrtTrackBufferCommand();
|
|
30
|
+
addVrtTrackBase64Command();
|
|
27
31
|
```
|
|
28
32
|
|
|
29
33
|
### Add plugin
|
|
@@ -128,6 +132,7 @@ cy.vrtTrack("Whole page with additional options", {
|
|
|
128
132
|
viewport: "1920x1080",
|
|
129
133
|
os: "MacOS",
|
|
130
134
|
device: "Cloud agent",
|
|
135
|
+
customTags: "Cloud, DarkTheme, Auth",
|
|
131
136
|
diffTollerancePercent: 1,
|
|
132
137
|
ignoreAreas: [{ x: 1, y: 2, width: 100, height: 200 }],
|
|
133
138
|
retryLimit: 2,
|
package/dist/commands.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const addVrtStartCommand: () => void;
|
|
2
2
|
export declare const addVrtStopCommand: () => void;
|
|
3
3
|
export declare const addVrtTrackCommand: () => void;
|
|
4
|
+
export declare const addVrtTrackBufferCommand: () => void;
|
|
5
|
+
export declare const addVrtTrackBase64Command: () => void;
|
package/dist/commands.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addVrtTrackCommand = exports.addVrtStopCommand = exports.addVrtStartCommand = void 0;
|
|
3
|
+
exports.addVrtTrackBase64Command = exports.addVrtTrackBufferCommand = exports.addVrtTrackCommand = exports.addVrtStopCommand = exports.addVrtStartCommand = void 0;
|
|
4
4
|
/* global Cypress, cy */
|
|
5
5
|
var utils_1 = require("./utils");
|
|
6
6
|
var addVrtStartCommand = function () {
|
|
@@ -31,3 +31,23 @@ var addVrtTrackCommand = function () {
|
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
33
|
exports.addVrtTrackCommand = addVrtTrackCommand;
|
|
34
|
+
var addVrtTrackBufferCommand = function () {
|
|
35
|
+
return Cypress.Commands.add("vrtTrackBuffer", {
|
|
36
|
+
prevSubject: false,
|
|
37
|
+
}, function (name, imageBuffer, options) {
|
|
38
|
+
(0, utils_1.trackBuffer)(name, imageBuffer, options).then(function (result) {
|
|
39
|
+
return (0, utils_1.checkResult)(result);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.addVrtTrackBufferCommand = addVrtTrackBufferCommand;
|
|
44
|
+
var addVrtTrackBase64Command = function () {
|
|
45
|
+
return Cypress.Commands.add("vrtTrackBase64", {
|
|
46
|
+
prevSubject: false,
|
|
47
|
+
}, function (name, imageBase64, options) {
|
|
48
|
+
(0, utils_1.trackBase64)(name, imageBase64, options).then(function (result) {
|
|
49
|
+
return (0, utils_1.checkResult)(result);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
exports.addVrtTrackBase64Command = addVrtTrackBase64Command;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
declare namespace Cypress {
|
|
3
4
|
interface Chainable {
|
|
4
5
|
/**
|
|
@@ -11,6 +12,7 @@ declare namespace Cypress {
|
|
|
11
12
|
* cy.get("#id").vrtTrack("name", {
|
|
12
13
|
* os: "MacOS",
|
|
13
14
|
* device: "Cloud agent",
|
|
15
|
+
* customTags: "Cloud, DarkTheme, Auth",
|
|
14
16
|
* diffTollerancePercent: 1.23,
|
|
15
17
|
* ignoreAreas: [
|
|
16
18
|
* {x: 1, y: 2, width: 100, height: 200}
|
|
@@ -19,6 +21,8 @@ declare namespace Cypress {
|
|
|
19
21
|
* })
|
|
20
22
|
*/
|
|
21
23
|
vrtTrack(name: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions>): Chainable<null>;
|
|
24
|
+
vrtTrackBuffer(name: string, imageBuffer: Buffer, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions>): Chainable<null>;
|
|
25
|
+
vrtTrackBase64(name: string, imageBase64: string, options?: Partial<Loggable & Timeoutable & ScreenshotOptions & TrackOptions>): Chainable<null>;
|
|
22
26
|
vrtStart(): null;
|
|
23
27
|
vrtStop(): null;
|
|
24
28
|
}
|
|
@@ -32,6 +36,7 @@ declare namespace Cypress {
|
|
|
32
36
|
viewport?: string;
|
|
33
37
|
os?: string;
|
|
34
38
|
device?: string;
|
|
39
|
+
customTags?: string;
|
|
35
40
|
diffTollerancePercent?: number;
|
|
36
41
|
ignoreAreas?: IgnoreArea[];
|
|
37
42
|
retryLimit?: number;
|
package/dist/plugin.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -87,24 +98,39 @@ function addVisualRegressionTrackerPlugin(on, config) {
|
|
|
87
98
|
});
|
|
88
99
|
}); },
|
|
89
100
|
_a["VRT_TRACK_IMAGE_MULTIPART"] = function (props) { return __awaiter(_this, void 0, void 0, function () {
|
|
90
|
-
var
|
|
101
|
+
var data, result;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
data = (0, sdk_js_1.multipartDtoToFormData)(__assign(__assign({}, props), { buildId: vrt.buildId, projectId: vrt.projectId, branchName: vrt.config.branchName }));
|
|
106
|
+
return [4 /*yield*/, vrt["submitTestRunMultipart"](data)];
|
|
107
|
+
case 1:
|
|
108
|
+
result = _a.sent();
|
|
109
|
+
(0, fs_1.unlinkSync)(props.imagePath);
|
|
110
|
+
return [2 /*return*/, result];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}); },
|
|
114
|
+
_a["VRT_TRACK_BUFFER_MULTIPART"] = function (props) { return __awaiter(_this, void 0, void 0, function () {
|
|
115
|
+
var data, result;
|
|
91
116
|
return __generator(this, function (_a) {
|
|
92
117
|
switch (_a.label) {
|
|
93
118
|
case 0:
|
|
94
|
-
|
|
95
|
-
return [4 /*yield*/, vrt["submitTestRunMultipart"](
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
119
|
+
data = (0, sdk_js_1.bufferDtoToFormData)(__assign(__assign({}, props), { buildId: vrt.buildId, projectId: vrt.projectId, branchName: vrt.config.branchName }));
|
|
120
|
+
return [4 /*yield*/, vrt["submitTestRunMultipart"](data)];
|
|
121
|
+
case 1:
|
|
122
|
+
result = _a.sent();
|
|
123
|
+
return [2 /*return*/, result];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}); },
|
|
127
|
+
_a["VRT_TRACK_IMAGE_BASE64"] = function (props) { return __awaiter(_this, void 0, void 0, function () {
|
|
128
|
+
var result;
|
|
129
|
+
return __generator(this, function (_a) {
|
|
130
|
+
switch (_a.label) {
|
|
131
|
+
case 0: return [4 /*yield*/, vrt["submitTestRunBase64"](props)];
|
|
105
132
|
case 1:
|
|
106
133
|
result = _a.sent();
|
|
107
|
-
(0, fs_1.unlinkSync)(imagePath);
|
|
108
134
|
return [2 /*return*/, result];
|
|
109
135
|
}
|
|
110
136
|
});
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { TestRunResponse } from "@visual-regression-tracker/sdk-js";
|
|
3
4
|
export declare const log: (message: string) => Cypress.Log;
|
|
4
5
|
export declare const handleError: (err: unknown) => void;
|
|
5
6
|
export declare const toTestRunDto: ({ name, pixelRatio, options, }: {
|
|
6
7
|
name: string;
|
|
7
|
-
pixelRatio
|
|
8
|
+
pixelRatio?: number | undefined;
|
|
8
9
|
options: any;
|
|
9
10
|
}) => {
|
|
10
11
|
name: string;
|
|
@@ -12,10 +13,13 @@ export declare const toTestRunDto: ({ name, pixelRatio, options, }: {
|
|
|
12
13
|
viewport: any;
|
|
13
14
|
os: any;
|
|
14
15
|
device: any;
|
|
16
|
+
customTags: any;
|
|
15
17
|
diffTollerancePercent: any;
|
|
16
18
|
ignoreAreas: any;
|
|
17
19
|
};
|
|
18
|
-
export declare const trackWithRetry: (trackFn: () => Cypress.Chainable<TestRunResponse>, shouldStopFn: (result: TestRunResponse) => boolean, onStopFn: (result: TestRunResponse) => Cypress.Chainable<unknown>, retryLimit?: number) =>
|
|
20
|
+
export declare const trackWithRetry: (trackFn: () => Cypress.Chainable<TestRunResponse>, shouldStopFn: (result: TestRunResponse) => boolean, onStopFn: (result: TestRunResponse) => Cypress.Chainable<unknown>, retryLimit?: number) => unknown;
|
|
19
21
|
export declare const checkResult: (result: TestRunResponse) => Cypress.Chainable<unknown>;
|
|
20
22
|
export declare const shouldStopRetry: (result: TestRunResponse) => boolean;
|
|
21
23
|
export declare const trackImage: (subject: any, name: string, options: any) => Cypress.Chainable<TestRunResponse>;
|
|
24
|
+
export declare const trackBuffer: (name: string, imageBuffer: Buffer, options: any) => Cypress.Chainable<TestRunResponse>;
|
|
25
|
+
export declare const trackBase64: (name: string, imageBase64: string, options: any) => Cypress.Chainable<TestRunResponse>;
|
package/dist/utils.js
CHANGED
|
@@ -12,7 +12,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
return __assign.apply(this, arguments);
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.trackImage = exports.shouldStopRetry = exports.checkResult = exports.trackWithRetry = exports.toTestRunDto = exports.handleError = exports.log = void 0;
|
|
15
|
+
exports.trackBase64 = exports.trackBuffer = exports.trackImage = exports.shouldStopRetry = exports.checkResult = exports.trackWithRetry = exports.toTestRunDto = exports.handleError = exports.log = void 0;
|
|
16
16
|
var sdk_js_1 = require("@visual-regression-tracker/sdk-js");
|
|
17
17
|
var log = function (message) {
|
|
18
18
|
return Cypress.log({
|
|
@@ -30,13 +30,14 @@ var handleError = function (err) {
|
|
|
30
30
|
exports.handleError = handleError;
|
|
31
31
|
var toTestRunDto = function (_a) {
|
|
32
32
|
var _b;
|
|
33
|
-
var name = _a.name,
|
|
33
|
+
var name = _a.name, _c = _a.pixelRatio, pixelRatio = _c === void 0 ? 1 : _c, options = _a.options;
|
|
34
34
|
return ({
|
|
35
35
|
name: name,
|
|
36
36
|
browser: Cypress.browser.name,
|
|
37
|
-
viewport: (_b = options === null || options === void 0 ? void 0 : options.viewport) !== null && _b !== void 0 ? _b : Cypress.config("viewportWidth") * pixelRatio
|
|
37
|
+
viewport: (_b = options === null || options === void 0 ? void 0 : options.viewport) !== null && _b !== void 0 ? _b : "".concat(Cypress.config("viewportWidth") * pixelRatio, "x").concat(Cypress.config("viewportHeight") * pixelRatio),
|
|
38
38
|
os: options === null || options === void 0 ? void 0 : options.os,
|
|
39
39
|
device: options === null || options === void 0 ? void 0 : options.device,
|
|
40
|
+
customTags: options === null || options === void 0 ? void 0 : options.customTags,
|
|
40
41
|
diffTollerancePercent: options === null || options === void 0 ? void 0 : options.diffTollerancePercent,
|
|
41
42
|
ignoreAreas: options === null || options === void 0 ? void 0 : options.ignoreAreas,
|
|
42
43
|
});
|
|
@@ -49,7 +50,7 @@ var trackWithRetry = function (trackFn, shouldStopFn, onStopFn, retryLimit) {
|
|
|
49
50
|
onStopFn(result);
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
|
-
(0, exports.log)("Diff found... Remaining retry attempts **"
|
|
53
|
+
(0, exports.log)("Diff found... Remaining retry attempts **".concat(retryLimit, "**"));
|
|
53
54
|
return (0, exports.trackWithRetry)(trackFn, shouldStopFn, onStopFn, retryLimit - 1);
|
|
54
55
|
});
|
|
55
56
|
};
|
|
@@ -72,9 +73,19 @@ var trackImage = function (subject, name, options) {
|
|
|
72
73
|
pixelRatio = props.pixelRatio;
|
|
73
74
|
return options === null || options === void 0 ? void 0 : options.onAfterScreenshot;
|
|
74
75
|
} }))
|
|
75
|
-
.then(function () { return (0, exports.log)("tracking "
|
|
76
|
+
.then(function () { return (0, exports.log)("tracking ".concat(name)); })
|
|
76
77
|
.then(function () {
|
|
77
78
|
return cy.task("VRT_TRACK_IMAGE_MULTIPART", __assign(__assign({}, (0, exports.toTestRunDto)({ name: name, pixelRatio: pixelRatio, options: options })), { imagePath: imagePath }), { log: false });
|
|
78
79
|
});
|
|
79
80
|
};
|
|
80
81
|
exports.trackImage = trackImage;
|
|
82
|
+
var trackBuffer = function (name, imageBuffer, options) {
|
|
83
|
+
(0, exports.log)("tracking ".concat(name));
|
|
84
|
+
return cy.task("VRT_TRACK_BUFFER_MULTIPART", __assign(__assign({}, (0, exports.toTestRunDto)({ name: name, options: options })), { imageBuffer: imageBuffer }), { log: false });
|
|
85
|
+
};
|
|
86
|
+
exports.trackBuffer = trackBuffer;
|
|
87
|
+
var trackBase64 = function (name, imageBase64, options) {
|
|
88
|
+
(0, exports.log)("tracking ".concat(name));
|
|
89
|
+
return cy.task("VRT_TRACK_IMAGE_BASE64", __assign(__assign({}, (0, exports.toTestRunDto)({ name: name, options: options })), { imageBase64: imageBase64 }), { log: false });
|
|
90
|
+
};
|
|
91
|
+
exports.trackBase64 = trackBase64;
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visual-regression-tracker/agent-cypress",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "Visual Regression Tracker integration plugin",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
5
7
|
"scripts": {
|
|
6
8
|
"test": "cypress run --spec 'cypress/integration/regression.spec.ts'",
|
|
7
9
|
"build": "tsc",
|
|
@@ -23,16 +25,16 @@
|
|
|
23
25
|
},
|
|
24
26
|
"homepage": "https://github.com/Visual-Regression-Tracker/agent-cypress#readme",
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"@visual-regression-tracker/sdk-js": "5.
|
|
28
|
+
"@visual-regression-tracker/sdk-js": "5.3.0"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
29
|
-
"@types/jest": "^
|
|
30
|
-
"@types/node": "^
|
|
31
|
-
"cypress": "^
|
|
32
|
-
"jest": "^
|
|
33
|
-
"semantic-release": "^
|
|
34
|
-
"ts-jest": "^
|
|
35
|
-
"typescript": "^4.
|
|
31
|
+
"@types/jest": "^27.4.1",
|
|
32
|
+
"@types/node": "^17.0.23",
|
|
33
|
+
"cypress": "^9.5.2",
|
|
34
|
+
"jest": "^27.5.1",
|
|
35
|
+
"semantic-release": "^19.0.2",
|
|
36
|
+
"ts-jest": "^27.1.4",
|
|
37
|
+
"typescript": "^4.6.3"
|
|
36
38
|
},
|
|
37
39
|
"publishConfig": {
|
|
38
40
|
"access": "public"
|