From 9d4efd1310c3ac4f6139824d0583e9ae2085c3c9 Mon Sep 17 00:00:00 2001 From: Akshit Sinha <34775769+akshitsinha@users.noreply.github.com> Date: Thu, 23 Feb 2023 14:13:13 +0530 Subject: [PATCH] fix(jest-circus): Send test case results for todo type of tests (#13915) --- CHANGELOG.md | 2 ++ .../customReportersOnCircus.test.ts.snap | 5 +++++ e2e/__tests__/customReportersOnCircus.test.ts | 15 +++++++++++++++ e2e/custom-reporters/__tests__/todo.test.js | 13 +++++++++++++ packages/jest-circus/src/testCaseReportHandler.ts | 1 + 5 files changed, 36 insertions(+) create mode 100644 e2e/custom-reporters/__tests__/todo.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index b691629f5139..5175123005fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ ### Fixes +- `[jest-circus]` Send test case results for `todo` tests ([#13915](https://github.com/facebook/jest/pull/13915)) + ### Chore & Maintenance ### Performance diff --git a/e2e/__tests__/__snapshots__/customReportersOnCircus.test.ts.snap b/e2e/__tests__/__snapshots__/customReportersOnCircus.test.ts.snap index 0867a8829991..0f5823c60467 100644 --- a/e2e/__tests__/__snapshots__/customReportersOnCircus.test.ts.snap +++ b/e2e/__tests__/__snapshots__/customReportersOnCircus.test.ts.snap @@ -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" +`; diff --git a/e2e/__tests__/customReportersOnCircus.test.ts b/e2e/__tests__/customReportersOnCircus.test.ts index 57f35e3b50e6..c6faf69467ae 100644 --- a/e2e/__tests__/customReportersOnCircus.test.ts +++ b/e2e/__tests__/customReportersOnCircus.test.ts @@ -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', + '/reporters/AssertionCountsReporter.js', + ], + }), + 'todo.test.js', + ]); + + expect(stdout).toMatchSnapshot(); + }); }); diff --git a/e2e/custom-reporters/__tests__/todo.test.js b/e2e/custom-reporters/__tests__/todo.test.js new file mode 100644 index 000000000000..9565e8a040e7 --- /dev/null +++ b/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'); +}); diff --git a/packages/jest-circus/src/testCaseReportHandler.ts b/packages/jest-circus/src/testCaseReportHandler.ts index 2711654e4dfe..f7633db2622e 100644 --- a/packages/jest-circus/src/testCaseReportHandler.ts +++ b/packages/jest-circus/src/testCaseReportHandler.ts @@ -13,6 +13,7 @@ const testCaseReportHandler = (testPath: string, sendMessageToJest: TestFileEvent) => (event: Circus.Event): void => { switch (event.name) { + case 'test_todo': case 'test_done': { const testResult = makeSingleTestResult(event.test); const testCaseResult = parseSingleTestResult(testResult);