-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsetupTests.ts
More file actions
35 lines (32 loc) · 1.06 KB
/
setupTests.ts
File metadata and controls
35 lines (32 loc) · 1.06 KB
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
27
28
29
30
31
32
33
34
35
import { NativeModules } from 'react-native';
import { jest } from '@jest/globals';
// Mock getInternalInstanceHandleFromPublicInstance since the testing library doesn't provide it
jest.mock(
'react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance',
() => {
const originalModule: any = jest.requireActual(
'react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance',
);
return {
...originalModule,
getInternalInstanceHandleFromPublicInstance: jest.fn((element: any) => {
// Return a mock structure that includes currentProps from the element
if (element && element._reactInternals && element._reactInternals.memoizedProps) {
return {
stateNode: {
canonical: {
currentProps: element._reactInternals.memoizedProps,
},
},
};
}
return null;
}),
};
},
);
NativeModules.FullStory = {
startPage: jest.fn(),
endPage: jest.fn(),
updatePage: jest.fn(),
};