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

Unable to find tests that contain [] in the file path #108

Closed
conermurphy opened this issue Mar 19, 2024 · 6 comments · Fixed by #109 or conermurphy/neotest-jest#1
Closed

Unable to find tests that contain [] in the file path #108

conermurphy opened this issue Mar 19, 2024 · 6 comments · Fixed by #109 or conermurphy/neotest-jest#1

Comments

@conermurphy
Copy link
Contributor

conermurphy commented Mar 19, 2024

When I try to run the tests in a file and that file's path contains the characters [] neotest is unable to find the test and returns a No tests found, exiting with code 1 error.

I came across this closed issue but it seems this bug still happens.

As an example this test file path would get the above no tests error: ./foo/[bar]/foo.test.ts.

However, this file path would be fine and run as expected ./foo/bar/foo.test.ts.

I've checked and the tests with the [] in the filename are correctly found by running Jest in the CLI and are able to be run in the VSCode Jest extension so I think the issue is specific to Neovim.

conermurphy added a commit to conermurphy/neotest-jest that referenced this issue Mar 19, 2024
Updates the file path parsing to escape special characters. This fixes nvim-neotest#108

Co-Authored-By: Luke Glazebrook <[email protected]>
@imfaber
Copy link

imfaber commented Mar 28, 2024

I have - in my paths and now they are no longer found with this change

@conermurphy
Copy link
Contributor Author

@imfaber, not sure what's happening there. I just tried with a test that has a path like this /foo/foo-bar/bar.test.ts and it picks it up okay in the summary page and runs the test correctly as well. Is your - in the directories or the file name of the test?

@imfaber
Copy link

imfaber commented Mar 28, 2024

@conermurphy in the directory but actually the overall path doesn't look good.
It should have only 2 \\

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\Users\fabri\dev\EnergyShop.HomeQgo-v2\Api\ClientApp
  1014 files checked.
  testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 171 matches
  testPathIgnorePatterns: \\node_modules\\, \\e2e - 994 matches
  testRegex:  - 0 matches
Pattern: C:\\\Users\\\fabri\\\dev\\\EnergyShop.HomeQgo\-v2\\\ClientApp\\\core\\\campaign.spec.ts - 0 matches

If I revert this change it works

Test Suites: 1 passed, 1 total
Tests:       1 skipped, 1 passed, 2 total
Snapshots:   0 total
Time:        3.103 s
Ran all test suites matching /C:\\Users\\fabri\\dev\\EnergyShop.HomeQgo-v2\\ClientApp\\core\\campaign.spec.ts/

@conermurphy
Copy link
Contributor Author

conermurphy commented Mar 28, 2024

@imfaber, are you running this on Windows? I'm presuming so by the C:/, maybe the issue is related to #44, this issue doesn't happen on MacOS so I'm thinking it's related to the issue described in that PR.

Could also be something happening in the escapeTestPattern function to add the extra \ in. Might be worth making a new issue for this to be looked into. I would offer but I don't have a Windows machine to test this out on.

@imfaber
Copy link

imfaber commented Mar 28, 2024

@conermurphy yes I'm on Windows and vim.fs.normalize introduced in #91 made paths work nicely.
Here the prob that I have is with this change where escapeTestPattern seems to break them.
I think back slashes are not the problem if they are properly escaped

@conermurphy
Copy link
Contributor Author

@imfaber, I just opened #113 to contain the conversation for this issue as while it's related to the changes in this PR, the new issue is unrelated to the bug described in this PR.

Happy to continue the conversation over there 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants