Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable testResultsProcessor to be async #13343

Merged
merged 4 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
SimenB marked this conversation as resolved.
Show resolved Hide resolved

### 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