@visual-regression-tracker/sdk-js 5.5.0 → 5.7.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/helpers/config.helper.js +6 -0
- package/dist/helpers/dto.helper.js +2 -0
- package/dist/helpers/track.helper.d.ts +2 -2
- package/dist/helpers/track.helper.js +1 -1
- package/dist/helpers/type.helper.d.ts +2 -1
- package/dist/helpers/type.helper.js +5 -1
- package/dist/types/config.d.ts +1 -0
- package/dist/types/request/testRun.dto.d.ts +1 -0
- package/dist/types/testStatus.js +1 -1
- package/dist/visualRegressionTracker.d.ts +1 -0
- package/dist/visualRegressionTracker.js +16 -12
- package/package.json +15 -12
|
@@ -12,6 +12,9 @@ const readConfigFromFile = (config) => {
|
|
|
12
12
|
if (fileConfig.branchName) {
|
|
13
13
|
config.branchName = fileConfig.branchName;
|
|
14
14
|
}
|
|
15
|
+
if (fileConfig.baselineBranchName) {
|
|
16
|
+
config.baselineBranchName = fileConfig.baselineBranchName;
|
|
17
|
+
}
|
|
15
18
|
if (fileConfig.project) {
|
|
16
19
|
config.project = fileConfig.project;
|
|
17
20
|
}
|
|
@@ -35,6 +38,9 @@ const readConfigFromEnv = (config) => {
|
|
|
35
38
|
if (process.env["VRT_BRANCHNAME"]) {
|
|
36
39
|
config.branchName = process.env["VRT_BRANCHNAME"];
|
|
37
40
|
}
|
|
41
|
+
if (process.env["VRT_BASELINEBRANCHNAME"]) {
|
|
42
|
+
config.baselineBranchName = process.env["VRT_BASELINEBRANCHNAME"];
|
|
43
|
+
}
|
|
38
44
|
if (process.env["VRT_PROJECT"]) {
|
|
39
45
|
config.project = process.env["VRT_PROJECT"];
|
|
40
46
|
}
|
|
@@ -11,6 +11,7 @@ const multipartDtoToFormData = (dto) => {
|
|
|
11
11
|
data.append("buildId", dto.buildId);
|
|
12
12
|
data.append("projectId", dto.projectId);
|
|
13
13
|
data.append("branchName", dto.branchName);
|
|
14
|
+
dto.baselineBranchName && data.append("baselineBranchName", dto.baselineBranchName);
|
|
14
15
|
data.append("name", dto.name);
|
|
15
16
|
data.append("image", fs_1.default.createReadStream(dto.imagePath), {
|
|
16
17
|
knownLength: fs_1.default.statSync(dto.imagePath).size,
|
|
@@ -33,6 +34,7 @@ const bufferDtoToFormData = (dto) => {
|
|
|
33
34
|
data.append("buildId", dto.buildId);
|
|
34
35
|
data.append("projectId", dto.projectId);
|
|
35
36
|
data.append("branchName", dto.branchName);
|
|
37
|
+
dto.baselineBranchName && data.append("baselineBranchName", dto.baselineBranchName);
|
|
36
38
|
data.append("name", dto.name);
|
|
37
39
|
data.append("image", dto.imageBuffer, { filename: "image.png" });
|
|
38
40
|
dto.os && data.append("os", dto.os);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TestRunResponse } from "../types";
|
|
2
|
-
export declare const processTestRun: (testRunResponse: TestRunResponse, enableSoftAssert?: boolean
|
|
2
|
+
export declare const processTestRun: (testRunResponse: TestRunResponse, enableSoftAssert?: boolean) => void;
|
|
3
3
|
export declare const shouldStopRetry: (result: TestRunResponse) => boolean;
|
|
4
|
-
export declare const trackWithRetry: (trackFn: () => Promise<TestRunResponse>, retryLimit
|
|
4
|
+
export declare const trackWithRetry: (trackFn: () => Promise<TestRunResponse>, retryLimit?: number, enableSoftAssert?: boolean) => Promise<TestRunResponse>;
|
|
@@ -36,7 +36,7 @@ const processTestRun = (testRunResponse, enableSoftAssert) => {
|
|
|
36
36
|
exports.processTestRun = processTestRun;
|
|
37
37
|
const shouldStopRetry = (result) => result.status !== types_1.TestStatus.unresolved;
|
|
38
38
|
exports.shouldStopRetry = shouldStopRetry;
|
|
39
|
-
const trackWithRetry = (trackFn, retryLimit, enableSoftAssert) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
const trackWithRetry = (trackFn, retryLimit = 2, enableSoftAssert) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
const result = yield trackFn();
|
|
41
41
|
if (retryLimit <= 0 || (0, exports.shouldStopRetry)(result)) {
|
|
42
42
|
(0, exports.processTestRun)(result, enableSoftAssert);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { TestRunBase64, TestRunBuffer } from "../types";
|
|
1
|
+
import { TestRunBase64, TestRunBuffer, TestRunMultipart } from "../types";
|
|
2
2
|
export declare function instanceOfTestRunBase64(object: any): object is TestRunBase64;
|
|
3
3
|
export declare function instanceOfTestRunBuffer(object: any): object is TestRunBuffer;
|
|
4
|
+
export declare function instanceOfTestRunMultipart(object: any): object is TestRunMultipart;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.instanceOfTestRunBuffer = exports.instanceOfTestRunBase64 = void 0;
|
|
3
|
+
exports.instanceOfTestRunMultipart = exports.instanceOfTestRunBuffer = exports.instanceOfTestRunBase64 = void 0;
|
|
4
4
|
function instanceOfTestRunBase64(object) {
|
|
5
5
|
return "imageBase64" in object;
|
|
6
6
|
}
|
|
@@ -9,3 +9,7 @@ function instanceOfTestRunBuffer(object) {
|
|
|
9
9
|
return "imageBuffer" in object;
|
|
10
10
|
}
|
|
11
11
|
exports.instanceOfTestRunBuffer = instanceOfTestRunBuffer;
|
|
12
|
+
function instanceOfTestRunMultipart(object) {
|
|
13
|
+
return "imagePath" in object;
|
|
14
|
+
}
|
|
15
|
+
exports.instanceOfTestRunMultipart = instanceOfTestRunMultipart;
|
package/dist/types/config.d.ts
CHANGED
package/dist/types/testStatus.js
CHANGED
|
@@ -48,6 +48,7 @@ class VisualRegressionTracker {
|
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
const data = {
|
|
50
50
|
branchName: this.config.branchName,
|
|
51
|
+
baselineBranchName: this.config.baselineBranchName,
|
|
51
52
|
project: this.config.project,
|
|
52
53
|
ciBuildId: this.config.ciBuildId,
|
|
53
54
|
};
|
|
@@ -75,7 +76,7 @@ class VisualRegressionTracker {
|
|
|
75
76
|
}
|
|
76
77
|
submitTestRunBase64(test) {
|
|
77
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
const data = Object.assign({ buildId: this.buildId, projectId: this.projectId, branchName: this.config.branchName }, test);
|
|
79
|
+
const data = Object.assign({ buildId: this.buildId, projectId: this.projectId, branchName: this.config.branchName, baselineBranchName: this.config.baselineBranchName }, test);
|
|
79
80
|
return axios_1.default
|
|
80
81
|
.post(`${this.config.apiUrl}/test-runs`, data, this.axiosConfig)
|
|
81
82
|
.then(this.handleResponse)
|
|
@@ -84,10 +85,11 @@ class VisualRegressionTracker {
|
|
|
84
85
|
}
|
|
85
86
|
submitTestRunMultipart(data) {
|
|
86
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
|
|
88
|
-
.post(`${this.config.apiUrl}/test-runs/multipart`, data, {
|
|
88
|
+
const config = {
|
|
89
89
|
headers: Object.assign(Object.assign(Object.assign({}, data.getHeaders()), { "Content-Length": data.getLengthSync() }), this.axiosConfig.headers),
|
|
90
|
-
}
|
|
90
|
+
};
|
|
91
|
+
return axios_1.default
|
|
92
|
+
.post(`${this.config.apiUrl}/test-runs/multipart`, data, config)
|
|
91
93
|
.then(this.handleResponse)
|
|
92
94
|
.catch(this.handleException);
|
|
93
95
|
});
|
|
@@ -115,6 +117,15 @@ class VisualRegressionTracker {
|
|
|
115
117
|
}
|
|
116
118
|
});
|
|
117
119
|
}
|
|
120
|
+
getFormData(test) {
|
|
121
|
+
if ((0, helpers_1.instanceOfTestRunBuffer)(test)) {
|
|
122
|
+
return (0, helpers_1.bufferDtoToFormData)(Object.assign({ buildId: this.buildId, projectId: this.projectId, branchName: this.config.branchName, baselineBranchName: this.config.baselineBranchName }, test));
|
|
123
|
+
}
|
|
124
|
+
else if ((0, helpers_1.instanceOfTestRunMultipart)(test)) {
|
|
125
|
+
return (0, helpers_1.multipartDtoToFormData)(Object.assign({ buildId: this.buildId, projectId: this.projectId, branchName: this.config.branchName, baselineBranchName: this.config.baselineBranchName }, test));
|
|
126
|
+
}
|
|
127
|
+
throw new Error("Invalid test run data");
|
|
128
|
+
}
|
|
118
129
|
/**
|
|
119
130
|
* Submit test data to external VRT service
|
|
120
131
|
*
|
|
@@ -132,14 +143,7 @@ class VisualRegressionTracker {
|
|
|
132
143
|
testRunResponse = yield (0, helpers_1.trackWithRetry)(() => this.submitTestRunBase64(test), retryCount, this.config.enableSoftAssert);
|
|
133
144
|
}
|
|
134
145
|
else {
|
|
135
|
-
|
|
136
|
-
if ((0, helpers_1.instanceOfTestRunBuffer)(test)) {
|
|
137
|
-
formData = (0, helpers_1.bufferDtoToFormData)(Object.assign({ buildId: this.buildId, projectId: this.projectId, branchName: this.config.branchName }, test));
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
formData = (0, helpers_1.multipartDtoToFormData)(Object.assign({ buildId: this.buildId, projectId: this.projectId, branchName: this.config.branchName }, test));
|
|
141
|
-
}
|
|
142
|
-
testRunResponse = yield (0, helpers_1.trackWithRetry)(() => this.submitTestRunMultipart(formData), retryCount, this.config.enableSoftAssert);
|
|
146
|
+
testRunResponse = yield (0, helpers_1.trackWithRetry)(() => this.submitTestRunMultipart(this.getFormData(test)), retryCount, this.config.enableSoftAssert);
|
|
143
147
|
}
|
|
144
148
|
return new testRunResult_1.default(testRunResponse, this.config.apiUrl);
|
|
145
149
|
});
|
package/package.json
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visual-regression-tracker/sdk-js",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "jest",
|
|
9
9
|
"test:cov": "jest --collectCoverage",
|
|
10
|
-
"build": "
|
|
10
|
+
"build": "tsc"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/Visual-Regression-Tracker/
|
|
14
|
+
"url": "git+https://github.com/Visual-Regression-Tracker/sdk-js.git"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
15
18
|
},
|
|
16
19
|
"author": "",
|
|
17
|
-
"license": "
|
|
20
|
+
"license": "Apache-2.0",
|
|
18
21
|
"bugs": {
|
|
19
|
-
"url": "https://github.com/Visual-Regression-Tracker/
|
|
22
|
+
"url": "https://github.com/Visual-Regression-Tracker/sdk-js/issues"
|
|
20
23
|
},
|
|
21
24
|
"homepage": "https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker",
|
|
22
25
|
"dependencies": {
|
|
23
|
-
"axios": "^
|
|
26
|
+
"axios": "^1.4.0",
|
|
24
27
|
"form-data": "^4.0.0"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
|
-
"@types/jest": "^
|
|
28
|
-
"@types/node": "^
|
|
29
|
-
"jest": "^
|
|
30
|
-
"semantic-release": "^
|
|
31
|
-
"ts-jest": "^
|
|
32
|
-
"typescript": "^
|
|
30
|
+
"@types/jest": "^29.5.3",
|
|
31
|
+
"@types/node": "^16.18.38",
|
|
32
|
+
"jest": "^29.6.1",
|
|
33
|
+
"semantic-release": "^21.0.7",
|
|
34
|
+
"ts-jest": "^29.1.1",
|
|
35
|
+
"typescript": "^5.1.6"
|
|
33
36
|
},
|
|
34
37
|
"publishConfig": {
|
|
35
38
|
"access": "public"
|