@@ -143,6 +143,7 @@ describe('init', () => {
143
143
Object . defineProperty ( WINDOW , 'chrome' , { value : undefined , writable : true } ) ;
144
144
Object . defineProperty ( WINDOW , 'browser' , { value : undefined , writable : true } ) ;
145
145
Object . defineProperty ( WINDOW , 'nw' , { value : undefined , writable : true } ) ;
146
+ Object . defineProperty ( WINDOW , 'window' , { value : WINDOW , writable : true } ) ;
146
147
} ) ;
147
148
148
149
it ( 'logs a browser extension error if executed inside a Chrome extension' , ( ) => {
@@ -223,6 +224,18 @@ describe('init', () => {
223
224
consoleErrorSpy . mockRestore ( ) ;
224
225
} ) ;
225
226
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
+
226
239
it ( "doesn't return a client on initialization error" , ( ) => {
227
240
const consoleErrorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
228
241
0 commit comments