11import '@testing-library/jest-native/extend-expect' ;
2+
23import mockRNCNetInfo from '@react-native-community/netinfo/jest/netinfo-mock.js' ;
34import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock' ;
45
56import { jest } from '@jest/globals' ;
6- import { server } from './src/test/mocks/server' ;
77
88jest . mock ( '@react-native-community/netinfo' , ( ) => mockRNCNetInfo ) ;
99jest . mock ( '@react-native-async-storage/async-storage' , ( ) => mockAsyncStorage ) ;
1010
11- jest . mock ( '@sentry/react-native' , ( ) => ( {
11+ jest . doMock ( '@sentry/react-native' , ( ) => ( {
1212 init : jest . fn ( ) ,
1313} ) ) ;
1414
15- jest . mock ( 'react-native-reanimated' , ( ) => {
15+ jest . doMock ( 'react-native-reanimated' , ( ) => {
1616 // eslint-disable-next-line @typescript-eslint/no-var-requires
1717 const Reanimated = require ( 'react-native-reanimated/mock' ) ;
1818
@@ -24,7 +24,7 @@ jest.mock('react-native-reanimated', () => {
2424} ) ;
2525
2626// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
27- jest . mock ( 'react-native/Libraries/Animated/src/ NativeAnimatedHelper' ) ;
27+ jest . mock ( 'react-native/Libraries/Animated/NativeAnimatedHelper' ) ;
2828
2929jest . mock ( 'nanoid/non-secure' , ( ) => ( {
3030 nanoid : ( ) => 'routeUniqId' ,
@@ -42,7 +42,6 @@ jest.mock('react-native/Libraries/Components/Switch/Switch', () => {
4242 return mockComponent ( 'react-native/Libraries/Components/Switch/Switch' ) ;
4343} ) ;
4444
45- jest . mock ( 'react-native/Libraries/Animated/src/NativeAnimatedHelper' ) ;
4645jest . mock ( 'react-native-gesture-handler' , ( ) => {
4746 // eslint-disable-next-line @typescript-eslint/no-var-requires
4847 const View = require ( 'react-native/Libraries/Components/View/View' ) ;
@@ -78,9 +77,6 @@ jest.mock('react-native-gesture-handler', () => {
7877 } ;
7978} ) ;
8079
81- //establish api mocking before all tests
82- beforeAll ( ( ) => server . listen ( ) ) ;
83-
8480beforeEach ( ( ) => {
8581 global . fetch = jest . fn ( ( ...args ) => {
8682 console . warn ( 'global.fetch needs to be mocked in tests' , ...args ) ;
@@ -89,11 +85,9 @@ beforeEach(() => {
8985} ) ;
9086
9187//clean up after the tests are finished
92- afterAll ( ( ) => server . close ( ) ) ;
9388
9489afterEach ( ( ) => {
9590 global . fetch . mockRestore ( ) ;
9691 //reset any requests handlers that we may add during the tests,
9792 //so they don't affect other tests.
98- server . resetHandlers ( ) ;
9993} ) ;
0 commit comments