@percy/client 1.6.2 → 1.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/client.js +13 -7
- package/package.json +4 -4
- package/test/helpers.js +8 -6
package/dist/client.js
CHANGED
|
@@ -187,19 +187,25 @@ export class PercyClient {
|
|
|
187
187
|
timeout = 10 * 60 * 1000,
|
|
188
188
|
interval = 1000
|
|
189
189
|
}, onProgress) {
|
|
190
|
-
if (
|
|
190
|
+
if (!project && commit) {
|
|
191
191
|
throw new Error('Missing project path for commit');
|
|
192
|
-
} else if (!
|
|
193
|
-
throw new Error('Missing
|
|
192
|
+
} else if (!project && !build) {
|
|
193
|
+
throw new Error('Missing project path or build ID');
|
|
194
194
|
} else if (project) {
|
|
195
195
|
validateProjectPath(project);
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
commit || (commit = this.env.git.sha);
|
|
199
|
+
if (!build && !commit) throw new Error('Missing build commit');
|
|
198
200
|
let sha = commit && (git(`rev-parse ${commit}`) || commit);
|
|
199
201
|
|
|
200
|
-
let fetchData = async () =>
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
let fetchData = async () => {
|
|
203
|
+
var _await$this$getBuilds;
|
|
204
|
+
|
|
205
|
+
return build ? (await this.getBuild(build)).data : (_await$this$getBuilds = (await this.getBuilds(project, {
|
|
206
|
+
sha
|
|
207
|
+
})).data) === null || _await$this$getBuilds === void 0 ? void 0 : _await$this$getBuilds[0];
|
|
208
|
+
};
|
|
203
209
|
|
|
204
210
|
this.log.debug(`Waiting for build ${build || `${project} (${commit})`}...`); // recursively poll every second until the build finishes
|
|
205
211
|
|
|
@@ -213,7 +219,7 @@ export class PercyClient {
|
|
|
213
219
|
if (updated) {
|
|
214
220
|
t = Date.now(); // no new data within the timeout
|
|
215
221
|
} else if (Date.now() - t >= timeout) {
|
|
216
|
-
throw new Error('Timeout exceeded
|
|
222
|
+
throw new Error(state == null ? 'Build not found' : 'Timeout exceeded with no updates');
|
|
217
223
|
} // call progress every update after the first update
|
|
218
224
|
|
|
219
225
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"test:coverage": "yarn test --coverage"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@percy/env": "1.
|
|
35
|
-
"@percy/logger": "1.
|
|
34
|
+
"@percy/env": "1.7.0",
|
|
35
|
+
"@percy/logger": "1.7.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "f1418fb1effdaad2d32c65d1a358282ab1f9ec32"
|
|
38
38
|
}
|
package/test/helpers.js
CHANGED
|
@@ -79,17 +79,19 @@ export async function mockRequests(baseUrl, defaultReply = () => [200]) {
|
|
|
79
79
|
if (!jasmine.isSpy(http.request)) {
|
|
80
80
|
spyOn(http, 'request').and.callFake((...a) => new MockRequest(null, ...a));
|
|
81
81
|
spyOn(http, 'get').and.callFake((...a) => new MockRequest(null, ...a).end());
|
|
82
|
+
mockRequests.spies = new Map();
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
let any = jasmine.anything();
|
|
85
|
-
let match = o => o.hostname === hostname &&
|
|
86
|
-
(o.path ?? o.pathname).startsWith(pathname);
|
|
86
|
+
let match = o => o.hostname === hostname && (o.path ?? o.pathname).startsWith(pathname);
|
|
87
87
|
let reply = jasmine.createSpy('reply').and.callFake(defaultReply);
|
|
88
|
+
let spies = mockRequests.spies.get(baseUrl) ?? {};
|
|
88
89
|
|
|
89
|
-
http.request.withArgs({ asymmetricMatch: match })
|
|
90
|
-
|
|
91
|
-
http.get.withArgs({ asymmetricMatch: u => match(new URL(u)) }, any, any)
|
|
92
|
-
|
|
90
|
+
spies.request = spies.request ?? http.request.withArgs({ asymmetricMatch: match });
|
|
91
|
+
spies.request.and.callFake((...a) => new MockRequest(reply, ...a));
|
|
92
|
+
spies.get = spies.get ?? http.get.withArgs({ asymmetricMatch: u => match(new URL(u)) }, any, any);
|
|
93
|
+
spies.get.and.callFake((...a) => new MockRequest(reply, ...a).end());
|
|
94
|
+
mockRequests.spies.set(baseUrl, spies);
|
|
93
95
|
|
|
94
96
|
return reply;
|
|
95
97
|
}
|