@@ -143,6 +143,7 @@ describe('init', () => {
143143 Object . defineProperty ( WINDOW , 'chrome' , { value : undefined , writable : true } ) ;
144144 Object . defineProperty ( WINDOW , 'browser' , { value : undefined , writable : true } ) ;
145145 Object . defineProperty ( WINDOW , 'nw' , { value : undefined , writable : true } ) ;
146+ Object . defineProperty ( WINDOW , 'window' , { value : WINDOW , writable : true } ) ;
146147 } ) ;
147148
148149 it ( 'logs a browser extension error if executed inside a Chrome extension' , ( ) => {
@@ -223,6 +224,18 @@ describe('init', () => {
223224 consoleErrorSpy . mockRestore ( ) ;
224225 } ) ;
225226
227+ it ( "doesn't log a browser extension error if the `window` object isn't defined" , ( ) => {
228+ const consoleErrorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
229+
230+ Object . defineProperty ( WINDOW , 'window' , { value : undefined } ) ;
231+
232+ init ( options ) ;
233+
234+ expect ( consoleErrorSpy ) . not . toHaveBeenCalled ( ) ;
235+
236+ consoleErrorSpy . mockRestore ( ) ;
237+ } ) ;
238+
226239 it ( "doesn't return a client on initialization error" , ( ) => {
227240 const consoleErrorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
228241
0 commit comments