Skip to content

Commit 35e0187

Browse files
committed
msw: Avoid multiple setupWorker() calls
1 parent 03afc7c commit 35e0187

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/helpers/setup-msw.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import { setupWorker } from 'msw/browser';
66

77
import { setupFakeTimers } from './fake-timers';
88

9+
const worker = setupWorker(
10+
...handlers,
11+
http.get('/assets/*', passthrough),
12+
http.all(/.*\/percy\/.*/, passthrough),
13+
http.get('https://:avatars.githubusercontent.com/u/:id', passthrough),
14+
);
15+
916
export default function (hooks) {
1017
setupWindowMock(hooks);
1118
setupFakeTimers(hooks, '2017-11-20T12:00:00');
1219

13-
let worker = setupWorker(
14-
...handlers,
15-
http.get('/assets/*', passthrough),
16-
http.all(/.*\/percy\/.*/, passthrough),
17-
http.get('https://:avatars.githubusercontent.com/u/:id', passthrough),
18-
);
19-
2020
hooks.before(() => worker.start({ quiet: true, onUnhandledRequest: 'error' }));
2121
hooks.afterEach(() => worker.resetHandlers());
2222
hooks.afterEach(() => db.reset());

0 commit comments

Comments
 (0)