File tree Expand file tree Collapse file tree 2 files changed +5
-0
lines changed
app/network-requests/__tests__ Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { User } from '../types';
2
2
import { http , HttpResponse } from "msw" ;
3
3
import { setupServer } from "msw/node" ;
4
4
5
+ // Define request handlers and response resolvers for random user API.
6
+ // By default, we always return the happy path response.
5
7
const handlers = [
6
8
http . get ( 'https://randomuser.me/api/*' , ( ) => {
7
9
return HttpResponse . json ( DATA ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ import { server } from './app/network-requests/__tests__/test-utils';
7
7
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
8
8
jest . mock ( 'react-native/Libraries/Animated/NativeAnimatedHelper' ) ;
9
9
10
+ // Enable API mocking via Mock Service Worker (MSW)
10
11
beforeAll ( ( ) => server . listen ( ) ) ;
12
+ // Reset any runtime request handlers we may add during the tests
11
13
afterEach ( ( ) => server . resetHandlers ( ) ) ;
14
+ // Disable API mocking after the tests are done
12
15
afterAll ( ( ) => server . close ( ) ) ;
You can’t perform that action at this time.
0 commit comments