Skip to content

Commit

Permalink
Fix #13482: .todo tests are shown as todo when inside a focussed …
Browse files Browse the repository at this point in the history
…describe
  • Loading branch information
mattphillips committed Oct 24, 2022
1 parent 610b280 commit 1388ea7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
14 changes: 14 additions & 0 deletions e2e/__tests__/__snapshots__/testTodo.test.ts.snap
@@ -1,5 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`counts todo tests when inside of a \`describe.only\` 1`] = `
"PASS __tests__/only-todo.test.js
with .only, should show 'passed', 'todo', 'todo'
✓ passing test
✎ todo todo test 1
✎ todo todo test 2
Test Suites: 1 passed, 1 total
Tests: 2 todo, 1 passed, 3 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites matching /only-todo.test.js/i."
`;
exports[`shows error messages when called with invalid argument 1`] = `
"FAIL __tests__/todoNonString.test.js
● Test suite failed to run
Expand Down
7 changes: 7 additions & 0 deletions e2e/__tests__/testTodo.test.ts
Expand Up @@ -44,3 +44,10 @@ test('shows todo messages when in verbose mode', () => {
const {rest} = extractSummary(result.stderr);
expect(rest).toMatchSnapshot();
});

test('counts todo tests when inside of a `describe.only`', () => {
const result = runJest(dir, ['only-todo.test.js']);
expect(result.exitCode).toBe(0);
const {rest, summary} = extractSummary(result.stderr);
expect(`${rest}\n\n${summary}`).toMatchSnapshot();
});
13 changes: 13 additions & 0 deletions e2e/test-todo/__tests__/only-todo.test.js
@@ -0,0 +1,13 @@
/**
* 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.
*/
'use strict';

describe.only("with .only, should show 'passed', 'todo', 'todo'", () => {
test('passing test', () => {});
test.todo('todo test 1');
test.todo('todo test 2');
});
2 changes: 1 addition & 1 deletion packages/jest-circus/src/run.ts
Expand Up @@ -147,7 +147,7 @@ const _runTest = async (
const isSkipped =
parentSkipped ||
test.mode === 'skip' ||
(hasFocusedTests && test.mode !== 'only') ||
(hasFocusedTests && test.mode === undefined) ||
(testNamePattern && !testNamePattern.test(getTestID(test)));

if (isSkipped) {
Expand Down

0 comments on commit 1388ea7

Please sign in to comment.