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

fix(jest-circus): Send test case results for todo type of tests #13915

Merged
merged 5 commits into from Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,8 @@

### Fixes

- `[jest-circus]` Send test case results for `todo` tests ([#13915](https://github.com/facebook/jest/pull/13915))

### Chore & Maintenance

### Performance
Expand Down
Expand Up @@ -9,3 +9,8 @@ exports[`Custom Reporters Integration on jest-circus valid passing assertion cou
"onTestCaseResult: adds ok, status: passed, numExpectations: 3
onTestFileResult testCaseResult 0: adds ok, status: passed, numExpectations: 3"
`;

exports[`Custom Reporters Integration on jest-circus push test case results for todo tests 1`] = `
"onTestCaseResult: sample, status: todo, numExpectations: 0
onTestFileResult testCaseResult 0: sample, status: todo, numExpectations: 0"
`;
15 changes: 15 additions & 0 deletions e2e/__tests__/customReportersOnCircus.test.ts
Expand Up @@ -39,4 +39,19 @@ describe('Custom Reporters Integration on jest-circus', () => {

expect(stdout).toMatchSnapshot();
});

test('push test case results for todo tests', () => {
const {stdout} = runJest('custom-reporters', [
'--config',
JSON.stringify({
reporters: [
'default',
'<rootDir>/reporters/AssertionCountsReporter.js',
],
}),
'todo.test.js',
]);

expect(stdout).toMatchSnapshot();
});
});
13 changes: 13 additions & 0 deletions e2e/custom-reporters/__tests__/todo.test.js
@@ -0,0 +1,13 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

'use strict';

describe('Custom Reporters', () => {
it.todo('sample');
});
1 change: 1 addition & 0 deletions packages/jest-circus/src/testCaseReportHandler.ts
Expand Up @@ -13,6 +13,7 @@ const testCaseReportHandler =
(testPath: string, sendMessageToJest: TestFileEvent) =>
(event: Circus.Event): void => {
switch (event.name) {
case 'test_todo':
case 'test_done': {
akshitsinha marked this conversation as resolved.
Show resolved Hide resolved
const testResult = makeSingleTestResult(event.test);
const testCaseResult = parseSingleTestResult(testResult);
Expand Down