-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Console messages emitted from Jest's beforeAll
hook do not cause failOnConsole
to fail the test
#33
Comments
Thanks for the detailed issue report. Unfortunately, I'm not sure that we can do something about this 😬 As far as I know, they run after Conceptually, I'm not sure we could make a test fail because this run before all tests. Therefore, which test should be failed in that case? That being said, we could at least update the README to explain this limitation. |
@ValentinH in this case I would be ok with not knowing which test failed. The most important thing would be that it fails at all. But I agree it might not be possible with the current architecture. |
A related use-case - we're relying on It would be great if that aspect (at least) could be fixed 🤞 |
Silencing might work if we also register our interceptors in a However, I'm still not sure if failing tests if we see that a non-silenced console is called could be done for the reasons I shared above. |
…al with messages emitted during beforeAll / afterAll in the client codebase See ValentinH#33
@ValentinH registering the inceptors in I had issues running the tests locally on
|
Thank you for taking the time. That's unfortunate that the tests are not runnable, are you on Windows? |
Yep
|
Ok that's means that some code in the tests system are not compatible with Windows unfortunately. |
We've just hit this issue as well. We merged a PR that didn't catch the React errors that were being logged before the tests started. Now, we're seeing numerous errors during test runs. The errors occurred before Jest executes
I agree with this, I'd rather have no errors than caring if it's tied to a specific test case. While we'll resolve our current React/jest issues, I'd like to prevent this happening again altogether. I have a branch that seems to resolve the issue (no tests yet). The way it works is it overrides each console implementation immediately once setup, then in the Does this change work for you @ValentinH? |
If the tests are still passing, I'm fine with this change. |
PR is up with a test. |
HI! First of all, thank you for this library, it was a godsend for us when cleaning up our messy unit test report :)
I think I have found a bug that caught us off guard, though. It seems that if the console is used in
beforeAll
(it might be other Jest hooks too, I just have not confirmed) it doesn't cause the tests to fail.Our configuration:
An example which will emit the following error:
Please take a look at this code sandbox: https://codesandbox.io/s/jest-fail-on-console-hooks-7rut79?file=/src/index.test.js
Unfortunately, even though Codesandbox supports Jest and the tests run, it doesn't seem to allow us to use any of the fake-timer controlling features due to this bug: codesandbox/codesandbox-client#513. Hopefully, this example is easy enough to reproduce locally.
The text was updated successfully, but these errors were encountered: