Skip to content

Commit abd7d83

Browse files
authored
.todo tests are shown as todo when inside a focussed describe (#13504)
1 parent 5fea130 commit abd7d83

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- `[@jest/test-sequencer]` Make sure sharding does not produce empty groups ([#13476](https://github.com/facebook/jest/pull/13476))
8+
- `[jest-circus]` Test marked as `todo` are shown as todo when inside a focussed describe ([#13504](https://github.com/facebook/jest/pull/13504))
89
- `[jest-mock]` Ensure mock resolved and rejected values are promises from correct realm ([#13503](https://github.com/facebook/jest/pull/13503))
910

1011
### Chore & Maintenance

e2e/__tests__/__snapshots__/testTodo.test.ts.snap

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`counts todo tests when inside of a \`describe.only\` 1`] = `
4+
"PASS __tests__/only-todo.test.js
5+
with .only, should show 'passed', 'todo', 'todo'
6+
✓ passing test
7+
✎ todo todo test 1
8+
✎ todo todo test 2
9+
10+
Test Suites: 1 passed, 1 total
11+
Tests: 2 todo, 1 passed, 3 total
12+
Snapshots: 0 total
13+
Time: <<REPLACED>>
14+
Ran all test suites matching /only-todo.test.js/i."
15+
`;
16+
317
exports[`shows error messages when called with invalid argument 1`] = `
418
"FAIL __tests__/todoNonString.test.js
519
● Test suite failed to run

e2e/__tests__/testTodo.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ test('shows todo messages when in verbose mode', () => {
4444
const {rest} = extractSummary(result.stderr);
4545
expect(rest).toMatchSnapshot();
4646
});
47+
48+
test('counts todo tests when inside of a `describe.only`', () => {
49+
const result = runJest(dir, ['only-todo.test.js']);
50+
expect(result.exitCode).toBe(0);
51+
const {rest, summary} = extractSummary(result.stderr);
52+
expect(`${rest}\n\n${summary}`).toMatchSnapshot();
53+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
/* eslint-disable jest/no-focused-tests */
9+
10+
'use strict';
11+
12+
describe.only("with .only, should show 'passed', 'todo', 'todo'", () => {
13+
test('passing test', () => {});
14+
test.todo('todo test 1');
15+
test.todo('todo test 2');
16+
});

packages/jest-circus/src/run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const _runTest = async (
147147
const isSkipped =
148148
parentSkipped ||
149149
test.mode === 'skip' ||
150-
(hasFocusedTests && test.mode !== 'only') ||
150+
(hasFocusedTests && test.mode === undefined) ||
151151
(testNamePattern && !testNamePattern.test(getTestID(test)));
152152

153153
if (isSkipped) {

0 commit comments

Comments
 (0)