I am trying to mock console.warn/error but i can\'t. I use a third-party-library which calls console.warn inside it. I need to test was it called or wasn\'t. In my test case
You have to use global to access objects in the global context
global
global.console = {warn: jest.fn()} expect(console.warn).toBeCalled()
or use jest.spyOn added in 19.0.0
jest.spyOn
19.0.0
jest.spyOn(global.console, 'warn')