Skip to content

Commit

Permalink
.todo tests are shown as todo when inside a focussed describe (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattphillips authored Oct 24, 2022
1 parent 5fea130 commit abd7d83
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

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

### Chore & Maintenance
Expand Down
14 changes: 14 additions & 0 deletions e2e/__tests__/__snapshots__/testTodo.test.ts.snap
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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();
});
16 changes: 16 additions & 0 deletions e2e/test-todo/__tests__/only-todo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* 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.
*/

/* eslint-disable jest/no-focused-tests */

'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
Original file line number Diff line number Diff line change
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 abd7d83

Please sign in to comment.