-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjest-setup-after.ts
More file actions
26 lines (23 loc) · 739 Bytes
/
jest-setup-after.ts
File metadata and controls
26 lines (23 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import '@testing-library/jest-dom/extend-expect';
import { getPublicUrlFromRequest, mswMockServer } from './jest-utils';
beforeAll(() => {
mswMockServer.listen({
onUnhandledRequest: (request) => {
const publicUrl = getPublicUrlFromRequest(request);
const message = `captured a ${
request.method
} ${request.url.toString()} request without a corresponding request handler.
If you wish to intercept this request, consider creating a request handler for it:
rest.${request.method.toLowerCase()}('${publicUrl}', (req, res, ctx) => {
return res(ctx.text('body'))
})`;
fail(message);
},
});
});
afterEach(() => {
mswMockServer.resetHandlers();
});
afterAll(() => {
mswMockServer.close();
});