@@ -7,18 +7,27 @@ import { ReactNativeInfo } from '../../src/js/integrations/reactnativeinfo';
77let mockedIsHermesEnabled : jest . Mock < boolean , [ ] > ;
88let mockedIsTurboModuleEnabled : jest . Mock < boolean , [ ] > ;
99let mockedIsFabricEnabled : jest . Mock < boolean , [ ] > ;
10+ let mockedGetReactNativeVersion : jest . Mock < string , [ ] > ;
11+ let mockedGetHermesVersion : jest . Mock < string | undefined , [ ] > ;
12+ let mockedIsExpo : jest . Mock < boolean , [ ] > ;
1013
1114jest . mock ( '../../src/js/utils/environment' , ( ) => ( {
1215 isHermesEnabled : ( ) => mockedIsHermesEnabled ( ) ,
1316 isTurboModuleEnabled : ( ) => mockedIsTurboModuleEnabled ( ) ,
1417 isFabricEnabled : ( ) => mockedIsFabricEnabled ( ) ,
18+ getReactNativeVersion : ( ) => mockedGetReactNativeVersion ( ) ,
19+ getHermesVersion : ( ) => mockedGetHermesVersion ( ) ,
20+ isExpo : ( ) => mockedIsExpo ( ) ,
1521} ) ) ;
1622
1723describe ( 'React Native Info' , ( ) => {
1824 beforeEach ( ( ) => {
19- mockedIsHermesEnabled = jest . fn ( ) . mockReturnValue ( false ) ;
25+ mockedIsHermesEnabled = jest . fn ( ) . mockReturnValue ( true ) ;
2026 mockedIsTurboModuleEnabled = jest . fn ( ) . mockReturnValue ( false ) ;
2127 mockedIsFabricEnabled = jest . fn ( ) . mockReturnValue ( false ) ;
28+ mockedGetReactNativeVersion = jest . fn ( ) . mockReturnValue ( '1000.0.0-test' ) ;
29+ mockedGetHermesVersion = jest . fn ( ) . mockReturnValue ( undefined ) ;
30+ mockedIsExpo = jest . fn ( ) . mockReturnValue ( false ) ;
2231 } ) ;
2332
2433 afterEach ( ( ) => {
@@ -39,20 +48,28 @@ describe('React Native Info', () => {
3948 react_native_context : < ReactNativeContext > {
4049 turbo_module : false ,
4150 fabric : false ,
51+ js_engine : 'hermes' ,
52+ react_native_version : '1000.0.0-test' ,
53+ expo : false ,
4254 } ,
4355 } ,
56+ tags : {
57+ hermes : 'true' ,
58+ } ,
4459 } ) ;
4560 } ) ;
4661
4762 it ( 'adds hermes tag and js_engine to context if hermes enabled' , async ( ) => {
4863 mockedIsHermesEnabled = jest . fn ( ) . mockReturnValue ( true ) ;
64+ mockedGetHermesVersion = jest . fn ( ) . mockReturnValue ( 'for RN 999.0.0' ) ;
4965 const actualEvent = await executeIntegrationFor ( { } , { } ) ;
5066
5167 expectMocksToBeCalledOnce ( ) ;
5268 expect ( actualEvent ?. tags ?. hermes ) . toEqual ( 'true' ) ;
53- expect ( ( actualEvent ?. contexts ?. react_native_context as ReactNativeContext | undefined ) ?. js_engine ) . toEqual (
54- 'hermes' ,
55- ) ;
69+ expect ( actualEvent ?. contexts ?. react_native_context ) . toEqual ( expect . objectContaining ( {
70+ js_engine : 'hermes' ,
71+ hermes_version : 'for RN 999.0.0' ,
72+ } ) ) ;
5673 } ) ;
5774
5875 it ( 'does not override existing hermes tag' , async ( ) => {
@@ -69,6 +86,7 @@ describe('React Native Info', () => {
6986 } ) ;
7087
7188 it ( 'adds engine from rn error' , async ( ) => {
89+ mockedIsHermesEnabled = jest . fn ( ) . mockReturnValue ( false ) ;
7290 const mockedHint : EventHint = {
7391 originalException : < ReactNativeError > {
7492 jsEngine : 'test_engine' ,
0 commit comments