-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix(jest): basic --bail support #4115
Conversation
ec82bff
to
de6b982
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
The pull request has been tested via integration and extensive manual testing, so merging it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that's quite a pain you've had to handle there. Please see my comments/questions.
// a bug in Jest, where `onRunComplete` is called multiple times when | ||
// Jest runs with `--bail` and multiple workers, and `onRunComplete` | ||
// is implemented as an asynchronous long-running operation. | ||
this._lastRunComplete = this._pendingTestFiles.size === 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK so as a name, _lastRunComplete
is kind of confusing. It needs a name that better conveys the meaning behind it, namely of "aggregated results of the last call to onRunComplete()" - I reckon? WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, the flow here if incredibly hard to follow. Jest's fault, I know - but we need this thing somehow simplified. On the one hand, onRunComplete
is triggered multiple times, awaiting the currently set _lastRunComplete
. On the other, onTestFileResult
only resolves the last _lastRunComplete
(lol). What flow is being mitigated here, really?... I saw some of that is described in the issue's main description, but ideally, the code itself should convey the complete picture, regardless (or at least with complimentary commenting work).
|
||
if (earlyTeardown && lostTests > 0 && config.testRunner.retries > 0) { | ||
console.warn( | ||
'Jest aborted the test execution before all scheduled test files have been reported.\n' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TL;DR? 😅 Can this be made more concise, perhaps by replacing some of the description with the link to the github issue in Jest? 🤔
// @ts-expect-error TS2554 | ||
super.onRunComplete(testContexts, aggregatedResult); | ||
|
||
if (earlyTeardown && lostTests > 0 && config.testRunner.retries > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be nested under if (earlyTeardown) {
of line #93
Description
Related to jestjs/jest#14143
This PR attempts to bridge the challenging integration between Jest's
-bail
, Detox's--retries
, and the intertwined bugs and constraints. Here's a brief overview of the obstacles addressed:DetoxReporter#onRunComplete
invocation: Ensure it's called only once using cached promises and deferreds. Concurrent failures in other workers might trigger redundant invocations of the same callback.numTotalTestSuites
is greater than the count of known test files. In such cases, critical information for scheduling another re-run via Detox's--retries
becomes unavailable.globalTeardown
Management: Ensure our global teardown is executed. Given Jest's apathy towards this, we manually invoke Detox's internalcleanup()
function during early exits.While these interventions significantly improve the use of Jest's --bail, a notable limitation remains detailed in point (2). The best we can do is print a warning and give up on retrying.