You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
To test for logger input, the logger is mocked and then calls to the logger are checked (see #2463 for an example). However, this must be done every for every file that the logger is mocked in, which is a bit annoying.
Describe the solution you'd like
Create a manual mock of the logger, so that we can just call jest.mock('logger'); at the start of each test. The default implementation of manual mocks can also be overridden though it's a bit more finnicky to do so.
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
Cool suggestion, I think this makes sense if the setup code for the logger is long. Just wondering which functions you want to mock with the logger? If the mock is just warn, info, error for example, there might be an argument made for mocking them at the start of each test case instead so that the tests are totally independent and not based on outside "logic"
Cool suggestion, I think this makes sense if the setup code for the logger is long. Just wondering which functions you want to mock with the logger? If the mock is just warn, info, error for example, there might be an argument made for mocking them at the start of each test case instead so that the tests are totally independent and not based on outside "logic"
Actually after thinking and reading about this a bit more I realise there isn't much need to do a manual mock for the logger since as discussed in #2099 it makes more sense to test for logger calls than logger outputs. So the automatic mock of jest.mock('/path/to/logger'); would work just fine since it replaces all the methods with another method that just returns undefined.
Please confirm that you have searched existing issues in the repo
Yes, I have searched the existing issues
Any related issues?
#2099
What is the area that this feature belongs to?
Testing
Is your feature request related to a problem? Please describe.
To test for logger input, the logger is mocked and then calls to the logger are checked (see #2463 for an example). However, this must be done every for every file that the logger is mocked in, which is a bit annoying.
Describe the solution you'd like
Create a manual mock of the logger, so that we can just call
jest.mock('logger');
at the start of each test. The default implementation of manual mocks can also be overridden though it's a bit more finnicky to do so.Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: