File tree Expand file tree Collapse file tree
packages/jest-preset/jest Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111import NativeExceptionsManager from 'react-native/Libraries/Core/NativeExceptionsManager' ;
1212
13+ test ( 'NativeAnimatedHelper is a mock' , ( ) => {
14+ const consoleWarn = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
15+
16+ try {
17+ const NativeAnimatedHelper : {
18+ assertNativeAnimatedModule : ( ) => void ,
19+ nativeEventEmitter : { addListener : ( ) => void } ,
20+ shouldUseNativeDriver : ( ) => boolean ,
21+ } = jest . requireMock (
22+ 'react-native/src/private/animated/NativeAnimatedHelper' ,
23+ ) . default ;
24+
25+ expect (
26+ jest . isMockFunction ( NativeAnimatedHelper . assertNativeAnimatedModule ) ,
27+ ) . toBe ( true ) ;
28+ expect ( NativeAnimatedHelper . nativeEventEmitter ) . toBeDefined ( ) ;
29+ expect (
30+ jest . isMockFunction ( NativeAnimatedHelper . shouldUseNativeDriver ) ,
31+ ) . toBe ( false ) ;
32+ expect ( consoleWarn ) . not . toHaveBeenCalled ( ) ;
33+ } finally {
34+ consoleWarn. mockRestore ( ) ;
35+ }
36+ } ) ;
37+
1338test ( 'NativeExceptionsManager is a mock' , ( ) => {
1439 expect ( jest . isMockFunction ( NativeExceptionsManager . reportException ) ) . toBe (
1540 true ,
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ *
7+ * @flow strict-local
8+ * @format
9+ */
10+
11+ import typeof TNativeAnimatedHelper from 'react-native/src/private/animated/NativeAnimatedHelper' ;
12+
13+ const NativeAnimatedHelper = jest . requireActual < {
14+ default : TNativeAnimatedHelper ,
15+ } > ( 'react-native/src/private/animated/NativeAnimatedHelper' ) . default ;
16+
17+ const NativeAnimatedHelperMock : TNativeAnimatedHelper = {
18+ ...NativeAnimatedHelper ,
19+ assertNativeAnimatedModule : jest . fn ( ) ,
20+ } ;
21+
22+ export default NativeAnimatedHelperMock ;
Original file line number Diff line number Diff line change @@ -176,3 +176,7 @@ mock(
176176 // $FlowFixMe[incompatible-type]
177177 'm#./mocks/Vibration' ,
178178) ;
179+ mock (
180+ 'm#react-native/src/private/animated/NativeAnimatedHelper' ,
181+ 'm#./mocks/NativeAnimatedHelper' ,
182+ ) ;
You can’t perform that action at this time.
0 commit comments