@visual-regression-tracker/sdk-js 5.5.0 → 5.6.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 +1 -1
- 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/visualRegressionTracker.d.ts +1 -0
- package/dist/visualRegressionTracker.js +12 -9
- package/package.json +1 -1
|
@@ -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
2
|
export declare const processTestRun: (testRunResponse: TestRunResponse, enableSoftAssert?: boolean | undefined) => 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 | undefined) => 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
|
@@ -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)
|
|
@@ -115,6 +116,15 @@ class VisualRegressionTracker {
|
|
|
115
116
|
}
|
|
116
117
|
});
|
|
117
118
|
}
|
|
119
|
+
getFormData(test) {
|
|
120
|
+
if ((0, helpers_1.instanceOfTestRunBuffer)(test)) {
|
|
121
|
+
return (0, helpers_1.bufferDtoToFormData)(Object.assign({ buildId: this.buildId, projectId: this.projectId, branchName: this.config.branchName, baselineBranchName: this.config.baselineBranchName }, test));
|
|
122
|
+
}
|
|
123
|
+
else if ((0, helpers_1.instanceOfTestRunMultipart)(test)) {
|
|
124
|
+
return (0, helpers_1.multipartDtoToFormData)(Object.assign({ buildId: this.buildId, projectId: this.projectId, branchName: this.config.branchName, baselineBranchName: this.config.baselineBranchName }, test));
|
|
125
|
+
}
|
|
126
|
+
throw new Error("Invalid test run data");
|
|
127
|
+
}
|
|
118
128
|
/**
|
|
119
129
|
* Submit test data to external VRT service
|
|
120
130
|
*
|
|
@@ -132,14 +142,7 @@ class VisualRegressionTracker {
|
|
|
132
142
|
testRunResponse = yield (0, helpers_1.trackWithRetry)(() => this.submitTestRunBase64(test), retryCount, this.config.enableSoftAssert);
|
|
133
143
|
}
|
|
134
144
|
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);
|
|
145
|
+
testRunResponse = yield (0, helpers_1.trackWithRetry)(() => this.submitTestRunMultipart(this.getFormData(test)), retryCount, this.config.enableSoftAssert);
|
|
143
146
|
}
|
|
144
147
|
return new testRunResult_1.default(testRunResponse, this.config.apiUrl);
|
|
145
148
|
});
|