diff --git a/CHANGELOG.md b/CHANGELOG.md index a2471a370e38..675d72809183 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - `[jest-jasmine2]` Stop adding `:` after an error that has no message ([#9990](https://github.com/facebook/jest/pull/9990)) - `[jest-diff]` Control no diff message color with `commonColor` in diff options ([#9997](https://github.com/facebook/jest/pull/9997)) +- `[jest-circus]` Stop printing errors for individual tests when beforeAll fails ([#10004](https://github.com/facebook/jest/pull/10004)) ### Chore & Maintenance diff --git a/packages/jest-circus/src/eventHandler.ts b/packages/jest-circus/src/eventHandler.ts index dfe916a629a1..097f641246c9 100644 --- a/packages/jest-circus/src/eventHandler.ts +++ b/packages/jest-circus/src/eventHandler.ts @@ -9,7 +9,6 @@ import type {Circus} from '@jest/types'; import {TEST_TIMEOUT_SYMBOL} from './types'; import { - addErrorToEachTestUnderDescribe, describeBlockHasTests, getTestDuration, invariant, @@ -154,13 +153,8 @@ const eventHandler: Circus.EventHandler = ( case 'hook_failure': { const {test, describeBlock, error, hook} = event; const {asyncError, type} = hook; - - if (type === 'beforeAll') { + if (type === 'beforeAll' || type === 'afterAll') { invariant(describeBlock, 'always present for `*All` hooks'); - addErrorToEachTestUnderDescribe(describeBlock, error, asyncError); - } else if (type === 'afterAll') { - // Attaching `afterAll` errors to each test makes execution flow - // too complicated, so we'll consider them to be global. state.unhandledErrors.push([error, asyncError]); } else { invariant(test, 'always present for `*Each` hooks');