Skip to content

Commit f253045

Browse files
author
stevegalili
committed
Comments with implem. explanation
1 parent 336c00e commit f253045

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

examples/cookbook/app/network-requests/__tests__/test-utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { User } from '../types';
22
import {http, HttpResponse} from "msw";
33
import {setupServer} from "msw/node";
44

5+
// Define request handlers and response resolvers for random user API.
6+
// By default, we always return the happy path response.
57
const handlers = [
68
http.get('https://randomuser.me/api/*', () => {
79
return HttpResponse.json(DATA);

examples/cookbook/jest-setup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { server } from './app/network-requests/__tests__/test-utils';
77
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
88
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
99

10+
// Enable API mocking via Mock Service Worker (MSW)
1011
beforeAll(() => server.listen());
12+
// Reset any runtime request handlers we may add during the tests
1113
afterEach(() => server.resetHandlers());
14+
// Disable API mocking after the tests are done
1215
afterAll(() => server.close());

0 commit comments

Comments
 (0)