@@ -149,6 +149,7 @@ describe('init', () => {
149149 Object . defineProperty ( WINDOW , 'chrome' , { value : undefined , writable : true } ) ;
150150 Object . defineProperty ( WINDOW , 'browser' , { value : undefined , writable : true } ) ;
151151 Object . defineProperty ( WINDOW , 'nw' , { value : undefined , writable : true } ) ;
152+ Object . defineProperty ( WINDOW , 'window' , { value : WINDOW , writable : true } ) ;
152153 } ) ;
153154
154155 it ( 'logs a browser extension error if executed inside a Chrome extension' , ( ) => {
@@ -229,6 +230,18 @@ describe('init', () => {
229230 consoleErrorSpy . mockRestore ( ) ;
230231 } ) ;
231232
233+ it ( "doesn't log a browser extension error if the `window` object isn't defined" , ( ) => {
234+ const consoleErrorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
235+
236+ Object . defineProperty ( WINDOW , 'window' , { value : undefined } ) ;
237+
238+ init ( options ) ;
239+
240+ expect ( consoleErrorSpy ) . not . toHaveBeenCalled ( ) ;
241+
242+ consoleErrorSpy . mockRestore ( ) ;
243+ } ) ;
244+
232245 it ( "doesn't return a client on initialization error" , ( ) => {
233246 const consoleErrorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
234247
0 commit comments