Skip to content

Commit aae0d3a

Browse files
feat: Enable testResultsProcessor to be async (#13343)
1 parent 6be272b commit aae0d3a

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Features
44

5+
- `[jest-core]` Enable testResultsProcessor to be async ([#13343](https://github.com/facebook/jest/pull/13343))
6+
57
### Fixes
68

79
### Chore & Maintenance

e2e/__tests__/testResultsProcessor.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ test('testResultsProcessor', () => {
2020
expect(json.processed).toBe(true);
2121
});
2222

23+
test('testResultsProcessor async', () => {
24+
const processorPath = path.resolve(
25+
__dirname,
26+
'../test-results-processor/processorAsync.js',
27+
);
28+
const {json} = runWithJson('test-results-processor', [
29+
'--json',
30+
`--testResultsProcessor=${processorPath}`,
31+
]);
32+
expect(json.processed).toBe(true);
33+
});
34+
2335
test('testResultsProcessor written in ESM', () => {
2436
const processorPath = path.resolve(
2537
__dirname,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
module.exports = async function (results) {
9+
results.processed = true;
10+
return results;
11+
};

packages/jest-core/src/runJest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const processResults = async (
9999
const processor = await requireOrImportModule<TestResultsProcessor>(
100100
testResultsProcessor,
101101
);
102-
runResults = processor(runResults);
102+
runResults = await processor(runResults);
103103
}
104104
if (isJSON) {
105105
if (outputFile) {

0 commit comments

Comments
 (0)