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 4 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
23 changes: 23 additions & 0 deletions e2e/__tests__/customReporters.test.ts
Expand Up @@ -135,6 +135,29 @@ describe('Custom Reporters Integration', () => {
expect(stdout).toMatchSnapshot();
});

test('shows testCaseResult with todo', () => {
writeFiles(DIR, {
'__tests__/test.test.js': "it.todo('test');",
'package.json': JSON.stringify({
jest: {
reporters: ['default', '<rootDir>/reporter.js'],
},
}),
'reporter.js': `
'use strict';
module.exports = class Reporter {
onTestCaseResult(test, testCaseResult) {
console.log(testCaseResult.title)
}
};
`,
});

const {stdout, exitCode} = runJest(DIR);
expect(stdout).toBe('test');
expect(exitCode).toBe(0);
});

test('prints reporter errors', () => {
writeFiles(DIR, {
'__tests__/test.test.js': "test('test', () => {});",
Expand Down
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