jest-community / vscode-jest

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

[BUG] Invalid test path pattern generated when running a test on windows #1163

Closed Tiberriver256 closed 3 months ago

Tiberriver256 commented 3 months ago

Describe the bug When I attempt to run a single test it generates an invalid pattern if the filename has any period in it.

For example, if I have a file located at C:\my-project\src\mytest.test.tsx

The following pattern is generated: C:\my-project\src\mytest\.test\.tsx

The following should be generated: C:\my-project\src\mytest.test.tsx

**NOTE: Debugging a single test generates a valid testPathPattern it is only when I run a single test that I have this problem.

To Reproduce Steps to reproduce the behavior:

  1. Go to a file containing tests
  2. Right click on the icon in the side-bar
  3. Click Run Test
  4. See error

Expected behavior It should run the test

Screenshots image

Environment (please complete the following information):

Prerequisite

connectdotz commented 3 months ago

@Tiberriver256

This issue is a bit puzzling... Since all test files have dot separators, this should normally work with this extension. It seems possible that something specific in your environment might be causing the regex escape pattern to be interpreted differently.

If you could provide a sample repo, it would help us investigate further. If that's not possible, could you please provide some additional information?

  1. Do you have any custom configurations, such as jest.jestCommandLine?
  2. If you have a customized debug configuration (in your .vscode/launch.json), could you share it with us?
  3. Could you also show us the command that was spawned, as seen in the console.log? For reference, you can check How to see more debug info (self-diagnosis).

Thanks!

Tiberriver256 commented 3 months ago

I didn't have any custom commands.. but ended up upgrading to jest 29 for something unrelated and that seems to have fixed it 🤷‍♂️