Created
December 14, 2021 08:26
-
-
Save ThaddeusJiang/23302def855e520a8631a4c23661634b to your computer and use it in GitHub Desktop.
Jest mock console.log
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
it('console.log the text "hello"', () => { | |
console.log = jest.fn(); | |
log('hello'); | |
// The first argument of the first call to the function was 'hello' | |
expect(console.log).toHaveBeenCalledWith('hello'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment