From 70b2fcce3b94dd0d9d49233e1635f7432b98c276 Mon Sep 17 00:00:00 2001 From: cpojer Date: Sun, 19 Apr 2020 21:56:22 +0100 Subject: [PATCH] `[jest-runner]` Don't print warning to stdout when using `--json` --- CHANGELOG.md | 1 + e2e/__tests__/workerForceExit.test.ts | 4 ++-- packages/jest-runner/src/index.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4215de6b474b..52f457d7f9cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - `[jest-circus]` Throw on nested test definitions ([#9828](https://github.com/facebook/jest/pull/9828)) - `[jest-changed-files]` `--only-changed` should include staged files ([#9799](https://github.com/facebook/jest/pull/9799)) - `[jest-each]` `each` will throw an error when called with too many arguments ([#9818](https://github.com/facebook/jest/pull/9818)) +- `[jest-runner]` Don't print warning to stdout when using `--json` ([#9843](https://github.com/facebook/jest/pull/9843)) ### Chore & Maintenance diff --git a/e2e/__tests__/workerForceExit.test.ts b/e2e/__tests__/workerForceExit.test.ts index 884b2987c953..ec27fa0cd197 100644 --- a/e2e/__tests__/workerForceExit.test.ts +++ b/e2e/__tests__/workerForceExit.test.ts @@ -42,11 +42,11 @@ test('prints a warning if a worker is force exited', () => { }); `, }); - const {exitCode, stderr, stdout} = runJest(DIR, ['--maxWorkers=2']); + const {exitCode, stderr} = runJest(DIR, ['--maxWorkers=2']); expect(exitCode).toBe(0); verifyNumPassed(stderr); - expect(stdout).toContain('A worker process has failed to exit gracefully'); + expect(stderr).toContain('A worker process has failed to exit gracefully'); }); test('force exits a worker that fails to exit gracefully', async () => { diff --git a/packages/jest-runner/src/index.ts b/packages/jest-runner/src/index.ts index 518c07ad8f03..9cf5659426cb 100644 --- a/packages/jest-runner/src/index.ts +++ b/packages/jest-runner/src/index.ts @@ -194,7 +194,7 @@ class TestRunner { const cleanup = async () => { const {forceExited} = await worker.end(); if (forceExited) { - console.log( + console.error( chalk.yellow( 'A worker process has failed to exit gracefully and has been force exited. ' + 'This is likely caused by tests leaking due to improper teardown. ' +