Skip to content

Commit

Permalink
feat: Enable testResultsProcessor to be async (#13343)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannessjoberg authored Sep 30, 2022
1 parent 6be272b commit aae0d3a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Features

- `[jest-core]` Enable testResultsProcessor to be async ([#13343](https://github.com/facebook/jest/pull/13343))

### Fixes

### Chore & Maintenance
Expand Down
12 changes: 12 additions & 0 deletions e2e/__tests__/testResultsProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions e2e/test-results-processor/processorAsync.js
Original file line number Diff line number Diff line change
@@ -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;
};
2 changes: 1 addition & 1 deletion packages/jest-core/src/runJest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const processResults = async (
const processor = await requireOrImportModule<TestResultsProcessor>(
testResultsProcessor,
);
runResults = processor(runResults);
runResults = await processor(runResults);
}
if (isJSON) {
if (outputFile) {
Expand Down

0 comments on commit aae0d3a

Please sign in to comment.