Closed YasiTL closed 5 months ago
@YasiTL, this might sound strange, but this is actually the expected behavior. Let me explain why this happens and how people typically mitigate this issue:
it.each()
test directly?it.each()
, the descriptions often contain dynamic content (like "if $input expects $output"
) to differentiate tests. Before running the tests, these dynamic names are unresolved. If you pass such an unresolved name to Jest, it won't recognize it, and the test won't run. To prevent this, the extension fallbacks to the test's parent block when faced with unresolved names. In your case, it seems the parent block is the file itself; thus, all tests in that file are executed.it.each()
are resolved, allowing individual tests to be run as you've observed.it.each()
tests back to the original state mentioned above?A simple mitigation strategy is to enclose your it.each()
within a describe()
block with a static name. This ensures that if it.each()
names remain unresolved and the extension fallbacks to the parent block, only the it.each()
tests within that describe()
block are executed.
I hope this explanation clarifies your concerns. If you have further questions, please feel free to ask.
Describe the bug When attempting to run any test using a test.each() via the sidebar or the green play button by a test, the entire testing file runs instead of that specific test. Immediately forcing a stop will then expand all the tests, including each of the
each
cases, and you can then individually run the tests.To Reproduce Steps to reproduce the behavior:
it.each(...)
it.each(...)
are displayed as grey, open circles. (Image below)it.each()
. Notice that the entire test file runs, instead of the expected behavior of only the test usingit.each(...)
running, and expanding out the generated test cases. (Related GIF below)it.each()
.Note: A sample repo will help us identify the bug much faster. 🙏
Expected behavior After edits of a test file, users should be able to run tests that use
it.each(...)
without having to run the entire test file. Tests that useit.each(...)
should be picked up by the extension and labeled, and run individually.Screenshots Environment (please complete the following information):
node -v
: [v20.10.0]npm -v
oryarn --version
: [npm 10.2.3]Prerequisite
npx jest int
ornpx jest unit
The fastest (and the most fun) way to resolve the issue is to submit a pull request yourself. If you are interested, please check out the contribution guide, we look forward to seeing your PR...