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

.todo tests are shown as todo when inside a focussed describe #13504

Merged
merged 5 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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