MCPcopy
hub / github.com/jestjs/jest / _bailIfNeeded

Method _bailIfNeeded

packages/jest-core/src/TestScheduler.ts:452–483  ·  view source on GitHub ↗
(
    testContexts: Set<TestContext>,
    aggregatedResults: AggregatedResult,
    watcher: TestWatcher,
    allTests: Array<Test>,
  )

Source from the content-addressed store, hash-verified

450 }
451
452 private async _bailIfNeeded(
453 testContexts: Set<TestContext>,
454 aggregatedResults: AggregatedResult,
455 watcher: TestWatcher,
456 allTests: Array<Test>,
457 ): Promise<void> {
458 if (
459 this._globalConfig.bail !== 0 &&
460 aggregatedResults.numFailedTests >= this._globalConfig.bail
461 ) {
462 if (watcher.isWatchMode()) {
463 await watcher.setState({interrupted: true});
464 return;
465 }
466
467 try {
468 await this._dispatcher.onRunComplete(testContexts, aggregatedResults);
469 } finally {
470 // Perform global teardown if client configures `bail`
471 if (allTests.length > 0) {
472 performance.mark('jest/globalTeardown:start');
473 await runGlobalHook({
474 allTests,
475 globalConfig: this._globalConfig,
476 moduleName: 'globalTeardown',
477 });
478 performance.mark('jest/globalTeardown:end');
479 exit(this._globalConfig.testFailureExitCode);
480 }
481 }
482 }
483 }
484}
485
486const createAggregatedResults = (numTotalTestSuites: number) => {

Callers 1

onResultMethod · 0.95

Calls 5

runGlobalHookFunction · 0.85
exitFunction · 0.85
isWatchModeMethod · 0.80
setStateMethod · 0.65
onRunCompleteMethod · 0.45

Tested by

no test coverage detected