From d8cb1ab1fce810b40f8547f5c89361f267c4d695 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 28 Oct 2020 14:01:36 +0530 Subject: [PATCH 1/3] set exitcode to 1 if tests log after teardown --- e2e/__tests__/consoleAfterTeardown.test.ts | 2 +- packages/jest-runner/src/runTest.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/e2e/__tests__/consoleAfterTeardown.test.ts b/e2e/__tests__/consoleAfterTeardown.test.ts index fb1b6fa68b92..6f6d2e111381 100644 --- a/e2e/__tests__/consoleAfterTeardown.test.ts +++ b/e2e/__tests__/consoleAfterTeardown.test.ts @@ -13,7 +13,7 @@ test('console printing', () => { const {stderr, exitCode} = runJest('console-after-teardown'); const {rest} = extractSummary(stderr); - expect(exitCode).toBe(0); + expect(exitCode).toBe(1); const withoutTrace = rest.split('\n').slice(0, -3).join('\n'); diff --git a/packages/jest-runner/src/runTest.ts b/packages/jest-runner/src/runTest.ts index 4770bf5369c5..bd2c6fc92cc6 100644 --- a/packages/jest-runner/src/runTest.ts +++ b/packages/jest-runner/src/runTest.ts @@ -61,8 +61,7 @@ function freezeConsole( ); process.stderr.write('\n' + formattedError + '\n'); - // TODO: set exit code in Jest 25 - // process.exitCode = 1; + process.exitCode = 1; }; } From 90a77740d4471f40217c8633680ee25a813f98c4 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 28 Oct 2020 15:40:37 +0530 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef1f8926045a..79735793e2ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ ### Features - `[jest-core]` Add `findRelatedTests` and `nonFlagArgs` in allowed config options for `updateConfigAndRun` in watch plugins ([#10659](https://github.com/facebook/jest/pull/10659)) +- `[jest-runner]` [**BREAKING**] set exit code to 1 if test logs after teardown ([#10728](https://github.com/facebook/jest/pull/10728)) ### Fixes From b2d8515e0ea844fcb0a0923159785d5926644a07 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 4 Nov 2020 18:25:59 +0100 Subject: [PATCH 3/3] move changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79735793e2ea..c054d76233f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features - `[jest-config]` [**BREAKING**] Default to Node testing environment instead of browser (JSDOM) ([#9874](https://github.com/facebook/jest/pull/9874)) +- `[jest-runner]` [**BREAKING**] set exit code to 1 if test logs after teardown ([#10728](https://github.com/facebook/jest/pull/10728)) ### Fixes @@ -25,7 +26,6 @@ ### Features - `[jest-core]` Add `findRelatedTests` and `nonFlagArgs` in allowed config options for `updateConfigAndRun` in watch plugins ([#10659](https://github.com/facebook/jest/pull/10659)) -- `[jest-runner]` [**BREAKING**] set exit code to 1 if test logs after teardown ([#10728](https://github.com/facebook/jest/pull/10728)) ### Fixes