Helper to mock consola
See original GitHub issueWe often need to do something like this:
const mockReporter = {
error: jest.fn(),
info: jest.fn(),
success: jest.fn()
}
jest.mock('consola', () => ({
info: jest.fn(),
success: jest.fn(),
debug: jest.fn(),
withTag: jest.fn().mockImplementation(() => mockReporter)
}))
A helper for that would be nice 😃
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Jest: how to mock console when it is used by a third-party ...
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...
Read more >jest-mock-console - npm
Jest utility to mock the console. Latest version: 2.0.0, last published: 7 months ago. Start using jest-mock-console in your project by ...
Read more >Mock Functions - Jest
Mock functions allow you to test the links between code by erasing the actual implementation of a function, capturing calls to the function ......
Read more >Mocking console methods with Jest - Krasimir Tsonev
Mocking console methods with Jest / I'm recently working on two OS libraries. Both I'm unit testing with Jest.
Read more >Mock Functions · Jest
Mock functions make it easy to test the links between code by erasing the ... var bound = myMock.bind(b); bound(); console.log(myMock.mock.instances); ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@pi0 I’ll do it
@ricardogobbosouza Do you mind making a PR?