Skip to content

Commit

Permalink
✅ Allow mock API delay
Browse files Browse the repository at this point in the history
Delaying mock API responses should decrease race conditions within certain tests
  • Loading branch information
wwilsman committed Sep 24, 2020
1 parent a3f64ca commit 64b5fe1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/cli-snapshot/test/snapshot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('percy snapshot', () => {

beforeEach(() => {
process.env.PERCY_TOKEN = '<<PERCY_TOKEN>>';
mockAPI.start();
mockAPI.start(50);
});

afterEach(() => {
Expand Down
6 changes: 3 additions & 3 deletions packages/client/test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const mockAPI = {
requests: null,
replies: null,

start() {
start(delay = 0) {
nock.cleanAll();
nock.disableNetConnect();
nock.enableNetConnect('storage.googleapis.com|localhost|127.0.0.1');
Expand Down Expand Up @@ -62,8 +62,8 @@ const mockAPI = {
);
}

n.get(/.*/).reply(intercept);
n.post(/.*/).reply(intercept);
n.get(/.*/).delay(delay).reply(intercept);
n.post(/.*/).delay(delay).reply(intercept);
},

reply(path, handler) {
Expand Down

0 comments on commit 64b5fe1

Please sign in to comment.