Last active
January 19, 2021 00:11
-
-
Save psenger/f4b423a9699f339c8d8d2c32e1ad0113 to your computer and use it in GitHub Desktop.
[Jest - How to Monitor Console] #Jest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const warnConsole = jest.spyOn(console, "warn").mockImplementation(() => {}); | |
| const errorConsole = jest.spyOn(console, "error").mockImplementation(() => {}); | |
| const infoConsole = jest.spyOn(console, "info").mockImplementation(() => {}); | |
| expect(warnConsole).toBeCalledWith('...'); | |
| expect(errorConsole).toBeCalledWith('...'); | |
| expect(infoConsole).toBeCalledWith('...'); | |
| expect(warnConsole).not.toHaveBeenCalled(); | |
| expect(errorConsole).not.toHaveBeenCalled(); | |
| expect(infoConsole).not.toHaveBeenCalled(); | |
| warnConsole.mockReset(); | |
| errorConsole.mockReset(); | |
| infoConsole.mockReset(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment