@@ -131,7 +131,7 @@ const render = (component) => rtlRender(<Provider store={customStore}>{component
131131// };
132132
133133const MockErrorMsg = jest . fn ( ) ;
134- jest . mock ( '../components/ErrorMsg' , ( ) => ( ) => {
134+ jest . mock ( '../components/ErrorHandling/ ErrorMsg' , ( ) => ( ) => {
135135 MockErrorMsg ( ) ;
136136 return < div > MockErrorMsg</ div > ;
137137} ) ;
@@ -142,51 +142,56 @@ jest.mock('../components/ErrorMsg', () => () => {
142142// const dispatch = jest.fn();
143143// mockeduseStoreContext.mockImplementation(() => [state, dispatch]);
144144
145+ // added to fix broken tests
146+ const props = {
147+ port : null ,
148+ } ;
149+
145150describe ( 'unit testing for ErrorContainer.tsx' , ( ) => {
146151 test ( 'logo image renders as expected' , ( ) => {
147- render ( < ErrorContainer /> ) ;
152+ render ( < ErrorContainer { ... props } /> ) ; // added {...props} to fix broken test
148153 expect ( screen . getByAltText ( 'Reactime Logo' ) ) . toBeInTheDocument ( ) ;
149154 } ) ;
150155
151156 test ( 'ErrorMsg component renders as expected' , ( ) => {
152- render ( < ErrorContainer /> ) ;
157+ render ( < ErrorContainer { ... props } /> ) ; // added {...props} to fix broken test
153158 expect ( screen . getByText ( 'MockErrorMsg' ) ) . toBeInTheDocument ( ) ;
154159 } ) ;
155160
156161 test ( 'Reactime website shows as expected' , ( ) => {
157- render ( < ErrorContainer /> ) ;
162+ render ( < ErrorContainer { ... props } /> ) ; // added {...props} to fix broken test
158163 expect ( screen . getByText ( 'Please visit the Reactime Github for more info.' ) ) . toBeInTheDocument ( ) ;
159164 } ) ;
160165
161166 describe ( 'Loading Checks show up as expected' , ( ) => {
162167 test ( 'Content script launching check shows' , ( ) => {
163- render ( < ErrorContainer /> ) ;
168+ render ( < ErrorContainer { ... props } /> ) ; // added {...props} to fix broken test
164169 expect (
165170 screen . getByText ( `Checking if content script has been launched on current tab` ) ,
166171 ) . toBeInTheDocument ( ) ;
167172 } ) ;
168173 test ( 'React Dev Tool Install check shows' , ( ) => {
169- render ( < ErrorContainer /> ) ;
174+ render ( < ErrorContainer { ... props } /> ) ; // added {...props} to fix broken test
170175 expect (
171176 screen . getByText ( `Checking if React Dev Tools has been installed` ) ,
172177 ) . toBeInTheDocument ( ) ;
173178 } ) ;
174179 test ( 'Compatible app check shows' , ( ) => {
175- render ( < ErrorContainer /> ) ;
180+ render ( < ErrorContainer { ... props } /> ) ; // added {...props} to fix broken test
176181 expect ( screen . getByText ( `Checking if target is a compatible React app` ) ) . toBeInTheDocument ( ) ;
177182 } ) ;
178183 } ) ;
179184
180185 describe ( 'Launching header shows correct tab info' , ( ) => {
181186 test ( 'When currentTitle has no target' , ( ) => {
182- render ( < ErrorContainer /> ) ;
187+ render ( < ErrorContainer { ... props } /> ) ; // added {...props} to fix broken test
183188 expect ( screen . getByText ( `Launching Reactime on tab: No Target` ) ) . toBeInTheDocument ( ) ;
184189 expect ( screen . queryByText ( `Launching Reactime on tab: Test Page` ) ) . not . toBeInTheDocument ( ) ;
185190 } ) ;
186191
187192 test ( 'When currentTitle has a target title' , ( ) => {
188193 customInitialState . main . currentTitle = 'Test Page' ;
189- render ( < ErrorContainer /> ) ;
194+ render ( < ErrorContainer { ... props } /> ) ; // added {...props} to fix broken test
190195 expect ( screen . getByText ( `Launching Reactime on tab: Test Page` ) ) . toBeInTheDocument ( ) ;
191196 expect ( screen . queryByText ( `Launching Reactime on tab: No Target` ) ) . not . toBeInTheDocument ( ) ;
192197 } ) ;
0 commit comments