question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Running tests that match string causes non-matching suites to fail

See original GitHub issue

šŸ’„ Regression Report

When I set the -t CLI option to filter what tests are run, if there is a suite that doesnā€™t have any tests that match the string then it fails with:

 ā— Test suite failed to run

    Your test suite must contain at least one test.

      at node_modules/jest/node_modules/jest-cli/build/test_scheduler.js:245:22

My expectation would be that it behaves the same as v22, where any suites that have no matching tests are skipped.

Sorry if this issue already exists, I looked for it but couldnā€™t find anything that matched this problem. Iā€™ve also looked in the v23 changelog and couldnā€™t see this being a known breaking change.

Last working version

Worked up to version: 22.4.4

Stopped working in version: 23.0.0

To Reproduce

Steps to reproduce the behavior: Clone my repo (https://github.com/Crispioso/possible-jest-bug) and run the following commands in both /v22 and /v23 directories:

npm install
npm test

They both run the same tests and apply -t false so that it only runs tests with the string ā€˜falseā€™ in their title.

v22 skips the suite which has no matching tests whereas v23 throws an error instead.

Expected behavior

v23 to skip test suites that have no tests in them that match the -t patter, rather than error.

Link to repl or repo (highly encouraged)

https://github.com/Crispioso/possible-jest-bug

Run npx envinfo --preset jest

Paste the results here:

v23:

  System:
    OS: macOS Sierra 10.12.6
    CPU: x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
  Binaries:
    Node: 8.9.3 - /usr/local/bin/node
    Yarn: 1.0.2 - /usr/local/bin/yarn
    npm: 5.5.1 - /usr/local/bin/npm
  npmPackages:
    jest: 23.0.0 => 23.0.0

v22:

  System:
    OS: macOS Sierra 10.12.6
    CPU: x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
  Binaries:
    Node: 8.9.3 - /usr/local/bin/node
    Yarn: 1.0.2 - /usr/local/bin/yarn
    npm: 5.5.1 - /usr/local/bin/npm
  npmPackages:
    jest: 22.x => 22.4.4

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vanschroedercommented, Jul 2, 2018

Iā€™m getting this issue with npm test -- -u -t="test string" for all published versions of v23.x. My project is not using yarn and would prefer not to add another dependency so can not use the solution posted above

Itā€™s worth noting that this only seems to be an issue with jest version >= 23.1 Rolling back to jest v22.4.4 fixes this. However, rolling back will cause flags to go up with david-dm so is less than ideal, so using jest-cli 24.x for test filtering with regex for now while leaving the package version at 23.2 as a work around

0reactions
github-actions[bot]commented, May 12, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. Here's a framework you can use to fix them and keep your test suite healthy....
Read more >
Testing in Go: Failing Tests - Ilija Eftimov ā€
The testing package exposes two different modes: testing and benchmarking. While what we will be discussing here is transferable to benchmarkingĀ ...
Read more >
unittest ā€” Unit testing framework ā€” Python 3.11.1 ...
A test suite is a collection of test cases, test suites, or both. ... Only run test methods and classes that match the...
Read more >
How to run test cases in a specified file? - Stack Overflow
There are two ways. The easy one is to use the -run flag and provide a pattern matching names of the tests you...
Read more >
8 Running Tests and Analyzing Results - Erlang/OTP
Aborts the test run if one or more suites fail to compile (described earlier). ... If test execution fails, the function returns the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found