@@ -15,9 +15,10 @@ describe('Main', () => {
1515 expect ( title ) . toBe ( 'React Native Debugger - Connected (port 8081)' ) ;
1616 } ) ;
1717
18+ const delay200 = ( ) => delay ( 200 ) ;
19+ const delay500 = ( ) => delay ( 500 ) ;
20+
1821 describe ( 'Context Menu' , ( ) => {
19- const delay200 = ( ) => delay ( 200 ) ;
20- const delay500 = ( ) => delay ( 500 ) ;
2122 it ( 'should show AsyncStorage content as expected' , async ( ) => {
2223 const { client } = rndebugger ;
2324 await client . execute ( ( ) => window . invokeDevMethod ( 'showAsyncStorage' ) ) . then ( delay200 ) ;
@@ -43,10 +44,9 @@ describe('Main', () => {
4344 . tap ( )
4445 . then ( delay500 ) ;
4546
46- await client . execute ( ( ) => window . invokeDevMethod ( 'clearAsyncStorage' ) ) . then ( delay200 ) ;
47+ await client . execute ( ( ) => window . invokeDevMethod ( 'clearAsyncStorage' ) ) . then ( delay500 ) ;
4748 await client . execute ( ( ) => window . invokeDevMethod ( 'showAsyncStorage' ) ) . then ( delay200 ) ;
4849 const logs = await client . getRenderProcessLogs ( ) ;
49- // Print renderer process logs
5050 expect (
5151 logs . some ( log => log . message . indexOf ( '[RNDebugger] No AsyncStorage content.' ) > - 1 )
5252 ) . toBeTruthy ( ) ;
@@ -64,7 +64,6 @@ describe('Main', () => {
6464
6565 await client . execute ( ( ) => window . invokeDevMethod ( 'networkInspect' ) ) . then ( delay200 ) ;
6666 const logs = await client . getRenderProcessLogs ( ) ;
67- // Print renderer process logs
6867 expect (
6968 logs . some (
7069 log =>
@@ -74,4 +73,32 @@ describe('Main', () => {
7473 ) . toBeTruthy ( ) ;
7574 } ) ;
7675 } ) ;
76+
77+ describe ( 'React DevTools' , ( ) => {
78+ const waitingForReactConnect = client =>
79+ client . waitUntilTextExists (
80+ '#react-devtools-container > div > div:nth-child(1) > ul > li:nth-child(1)' ,
81+ 'Elements' ,
82+ 1000
83+ ) ;
84+
85+ it ( 'should connected to React DevTools' , async ( ) => {
86+ const { client } = rndebugger ;
87+ await waitingForReactConnect ( client ) ;
88+ } ) ;
89+
90+ it ( 'should reconnect to React DevTools if open the tab' , async ( ) => {
91+ const { client } = rndebugger ;
92+ await waitingForReactConnect ( client ) ;
93+ await rndebugger . webContents . send ( 'toggle-devtools' , 'react' ) . then ( delay500 ) ;
94+
95+ const logs = await client . getRenderProcessLogs ( ) ;
96+ expect ( logs . some ( log => log . message . indexOf ( 'closing devtools' ) > - 1 ) ) . toBeTruthy ( ) ;
97+
98+ await rndebugger . webContents . send ( 'toggle-devtools' , 'react' ) . then ( ( ) => delay ( 2000 ) ) ;
99+
100+ await client . getRenderProcessLogs ( ) ;
101+ await waitingForReactConnect ( client ) ;
102+ } ) ;
103+ } ) ;
77104} ) ;
0 commit comments