Open broyde opened 1 year ago
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
@SimenB wdyt about this hotfix (TestScheduler.ts
and runJest.ts
)?
Not the most beautiful one, but it should do the job... 🤔
I stubmled upon this bug in Detox. Some of users tried to run tests with --bail
and the results are horryifing 😭 the --bail
logic disregards both the test environment cleanup and the global teardown.
I'll create a workaround in Detox to fight this. Perhaps, I'll be postponing the process.exit()
inside onRunComplete
via our Jest reporter override. Not a bright solution but I have no options if I want to maintain support for Jest 27+.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This bug is also the reason why we can't use the jest-puppeteer's server
option:
the server remains running if some test fails with --bail
:(
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
There is a pull request actually without a review, so no wonder this is still stale. ☹️
@SimenB and the Jest team,
I genuinely appreciate and value the power and flexibility that Jest offers, however, the further I tinker with jest --bail
implementation, the more disheartened I get.
I've found myself having to navigate intricate workarounds, particularly to ensure 1) that globalTeardown
is called; 2) that Reporter#onRunComplete
isn't invoked multiple times by different failing workers in --bail
mode, especially when dealing with prolonged async operations.
While I've made efforts to address this with my proposed solution here, I'm beginning to feel it's merely a band-aid. I believe this issue needs a more comprehensive approach. I express this not as criticism but as feedback from someone deeply engaged with the tool. I hope you could share a few thoughts on this topic, especially if you're long aware of the design inconsistencies around --bail
.
Thank you for your understanding and continued dedication to the Jest community.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Oh, yeah, of course it is stale.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
🙄
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
🙄
@broyde did the idea with the reporter hack anyhow helped you, by the way?
@broyde did the idea with the reporter hack anyhow helped you, by the way?
@noomorph
Jest doesn't want to stop the server (by calling globalTeardown
), so the server has to stop by itself:
Instead of using the server
option in jest-puppeteer
config, I directly run the test server. It then starts jest --bail
as a sub-process and kills itself on sub-process' close
event.
I've been using this workaround for a few years and it doesn't really necessary to change it.
So, I didn't try the reporter hack.
Ah, that makes sense. Thanks for sharing!
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This issue is still relevant.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Yes, it is still relevant
Still relevant and causeing issues where it does not clear up third parties
@LizDodion just making sure you're aware it is possible to piggyback Reporter's onRunComplete(...)
method for cleaning up. Of course, this is a suboptimal experience, but it may be helpful nevertheless.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Still relevant (reproduced with jest v29.7.0).
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Relevant as always.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Still relevant.
@broyde +1
Maybe the fact that Jest 30 is coming will justify some attention to this? 🤷♂️ It's safe enough to start experimenting with this in the major version context, anyways.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Still relevant.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Version
29.5.0
Steps to reproduce
yarn install
yarn test
You should see result like this:
Optional steps (if you don't like
jest.test.js
- you could runfail.test.js
directly):yarn jest fail.test.js
You should see failed result followed by:
yarn jest fail.test.js --bail
You should see the same fail, but without TEARDOWN log.
Expected behavior
yarn jest fail.test.js --bail
outputs theTEARDOWN
message, soyarn test
passes:Actual behavior
yarn jest fail.test.js --bail
does not output theTEARDOWN
message, sowith bail
case ofyarn test
fails:Additional context
This report is about the same bug as automatically closed https://github.com/jestjs/jest/issues/10607. Here I've created a hopefully better example with test which actually checks the
jest
behavior by running failing test without and with--bail
option.You could also run this example on Repl.
Reproduces on different environments and nodejs versions.
Environment