jest-community / vscode-jest

The optimal flow for Jest based testing in VS Code
MIT License
2.84k stars 295 forks source link

First execution of individual test (it block) executes all tests of the file #1021

Closed FrankVisuals closed 1 year ago

FrankVisuals commented 1 year ago

Environment

  1. vscode-jest version: 5.2.3
  2. node -v: 16.19.0
  3. npm -v or yarn --version: npm 8.19.3
  4. npm ls jest or npm ls react-scripts (if you haven’t ejected): jest@29.5.0 ts-jest@29.1.0
  5. your vscode-jest settings if customized:
    • jest.jestCommandLine? `` (empty)
    • jest.autoRun? `` (off)
    • anything else that you think might be relevant? no
  6. Operating system: MacOS 13.2.1 (22D68)

Prerequisite

Steps to Reproduce

https://github.com/FrankVisuals/vscode-jest-issue

Freshly written Test:

image

Clicking only the test in line 4

image

But still executes both tests

image image

Afterwards, when clicking only one test, it works.

Relevant Debug Info

n/a

Expected Behavior

Also on first click it should execute only one test.

Actual Behavior

Executes all tests on first click of individual execution.


The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself. If you are interested, feel free to check out the contribution guide, we look forward to seeing your PR...

cpwood commented 1 year ago

Also experiencing this at the moment. Is there any workaround that anyone can think of (other than refactoring the tests to one-per-file)?

connectdotz commented 1 year ago

Yes, this is a bug. I will patch it soon. Thanks!

Note this only happens the first time if the file hasn't been run. Once the file (tests) have been executed, it will not happen again. So @cpwood I don't think you need to refactor your tests.

FrankVisuals commented 1 year ago

Thanks for the update!

AlvesJorge commented 1 year ago

This is still happening, worse yet, it is running tests that are meant to be skipped. If you want to try and reproduce I'm doing this exercise here (but it happens in general) https://exercism.org/tracks/javascript/exercises/dominoes

I click on one test to debug it, and instead it tries to run other tests in the file too, worse even, it runs tests that are marked with an "x" meaning they should be skipped. And it is only telling me this because it is encountering a type error.

Is this intended?