From 57ecb40e7ed6080a72b40fef4e9d24598577cbde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sj=C3=B6berg?= Date: Fri, 30 Sep 2022 14:13:37 +0200 Subject: [PATCH 1/4] feat: Enable testResultsProcessor to be async --- e2e/__tests__/testResultsProcessor.test.ts | 12 ++++++++++++ e2e/test-results-processor/processorAsync.js | 11 +++++++++++ packages/jest-core/src/runJest.ts | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 e2e/test-results-processor/processorAsync.js diff --git a/e2e/__tests__/testResultsProcessor.test.ts b/e2e/__tests__/testResultsProcessor.test.ts index 9c62291ba28a..9ee4b7fbf6b8 100644 --- a/e2e/__tests__/testResultsProcessor.test.ts +++ b/e2e/__tests__/testResultsProcessor.test.ts @@ -20,6 +20,18 @@ test('testResultsProcessor', () => { expect(json.processed).toBe(true); }); +test('testResultsProcessor async', () => { + const processorPath = path.resolve( + __dirname, + '../test-results-processor/processorAsync.js', + ); + const {json} = runWithJson('test-results-processor', [ + '--json', + `--testResultsProcessor=${processorPath}`, + ]); + expect(json.processed).toBe(true); +}); + test('testResultsProcessor written in ESM', () => { const processorPath = path.resolve( __dirname, diff --git a/e2e/test-results-processor/processorAsync.js b/e2e/test-results-processor/processorAsync.js new file mode 100644 index 000000000000..efe73f0b200e --- /dev/null +++ b/e2e/test-results-processor/processorAsync.js @@ -0,0 +1,11 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +module.exports = async function (results) { + results.processed = true; + return results; +}; diff --git a/packages/jest-core/src/runJest.ts b/packages/jest-core/src/runJest.ts index 7061d3d282e7..5f0d74cb25d1 100644 --- a/packages/jest-core/src/runJest.ts +++ b/packages/jest-core/src/runJest.ts @@ -99,7 +99,7 @@ const processResults = async ( const processor = await requireOrImportModule( testResultsProcessor, ); - runResults = processor(runResults); + runResults = await processor(runResults); } if (isJSON) { if (outputFile) { From 17fbf62fc20f11c58b4246803341ca1dca514707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sj=C3=B6berg?= Date: Fri, 30 Sep 2022 14:34:52 +0200 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfff58ba0d49..717ca5828c49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Features +[jest-core] Enable testResultsProcessor to be async (#13343) + ### Fixes ### Chore & Maintenance From 05096079297db5b6d30e6fe6063a8607678791aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sj=C3=B6berg?= Date: Fri, 30 Sep 2022 22:46:04 +0200 Subject: [PATCH 3/4] fix CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 717ca5828c49..4e703362db2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Features -[jest-core] Enable testResultsProcessor to be async (#13343) +[jest-core] Enable testResultsProcessor to be async ([#13343](https://github.com/facebook/jest/pull/13343)) ### Fixes From 4668741edb321d32a41105e3431cce699645b7d3 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 1 Oct 2022 01:11:22 +0200 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e703362db2b..a026cbe38a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Features -[jest-core] Enable testResultsProcessor to be async ([#13343](https://github.com/facebook/jest/pull/13343)) +- `[jest-core]` Enable testResultsProcessor to be async ([#13343](https://github.com/facebook/jest/pull/13343)) ### Fixes