Skip to content

Commit da24a60

Browse files
authored
Start build return build (#65)
#64
1 parent 6b3d494 commit da24a60

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

lib/visualRegressionTracker.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ describe("VisualRegressionTracker", () => {
208208
};
209209
mockedAxios.post.mockResolvedValueOnce({ data: build });
210210

211-
await vrt["start"]();
211+
const result = await vrt.start();
212212

213213
expect(mockedAxios.post).toHaveBeenCalledWith(
214214
`${config.apiUrl}/builds`,
@@ -225,6 +225,7 @@ describe("VisualRegressionTracker", () => {
225225
);
226226
expect(vrt["buildId"]).toBe(buildId);
227227
expect(vrt["projectId"]).toBe(projectId);
228+
expect(result).toBe(build);
228229
});
229230

230231
test("should handle exception", async () => {
@@ -233,7 +234,7 @@ describe("VisualRegressionTracker", () => {
233234
mockedAxios.post.mockRejectedValueOnce(axiosError401);
234235

235236
try {
236-
await vrt["start"]();
237+
await vrt.start();
237238
} catch {}
238239

239240
expect(handleExceptionMock).toHaveBeenCalledWith(axiosError401);

lib/visualRegressionTracker.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,22 @@ export class VisualRegressionTracker {
4343
return !!this.buildId && !!this.projectId;
4444
}
4545

46-
async start() {
46+
async start(): Promise<BuildResponse> {
4747
const data = {
4848
branchName: this.config.branchName,
4949
project: this.config.project,
5050
ciBuildId: this.config.ciBuildId,
5151
};
5252

53-
const build: BuildResponse = await axios
53+
return axios
5454
.post(`${this.config.apiUrl}/builds`, data, this.axiosConfig)
5555
.then(this.handleResponse)
56-
.catch(this.handleException);
57-
58-
this.buildId = build.id;
59-
this.projectId = build.projectId;
56+
.catch(this.handleException)
57+
.then((build: BuildResponse) => {
58+
this.buildId = build.id;
59+
this.projectId = build.projectId;
60+
return build;
61+
});
6062
}
6163

6264
async stop() {

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"axios": "^0.21.0"
2424
},
2525
"devDependencies": {
26-
"@types/jest": "^26.0.5",
27-
"@types/node": "^14.0.23",
26+
"@types/jest": "^26.0.19",
27+
"@types/node": "^14.14.16",
2828
"jest": "^25.5.4",
2929
"ts-jest": "^25.5.1",
3030
"typescript": "^3.9.7"

0 commit comments

Comments
 (0)