From 79233978fd40ad5cf9fec5916af3825a968067aa Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Thu, 7 May 2020 23:07:04 -0400 Subject: [PATCH 1/2] fix: stop printing the same error for individual tests when beforeAll fails --- packages/jest-circus/src/eventHandler.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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'); From c3b5facb8b2d82aaad8a9e44e8afb9d7cb3eaaf8 Mon Sep 17 00:00:00 2001 From: Volodymyr Date: Fri, 8 May 2020 00:23:13 -0400 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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