You have to use global to access objects in the global context
global.console = {warn: jest.fn()}
expect(console.warn).toBeCalled()
or use jest.spyOn added in 19.0.0
jest.spyOn(global.console, 'warn')
You have to use global to access objects in the global context
global.console = {warn: jest.fn()}
expect(console.warn).toBeCalled()
or use jest.spyOn added in 19.0.0
jest.spyOn(global.console, 'warn')