Debugging cannot find any test files
Describe the bug When telling VSC to debug the tests (all of them, a single test, a single file, or a single describe), will result in nothing happening, apart from a log in the debug console saying no test files were found.
To Reproduce
- Go to the testing panel
- Click the "Debug Tests" button
- If its not open already, open the debug console
Expected behavior The tests to run, using the debugger to stop at breakpoints and such
Screenshots
C:\Program Files\nodejs\node.exe .\node_modules\vitest\vitest.mjs vitest D:/projects/Kronos/tests/util/common.test.ts --api 65426
DEV v0.17.1 d:/projects/Kronos
API started at http://localhost:65426
filter: vitest, D:/projects/Kronos/tests/util/common.test.ts
include: **/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}
watch exclude: **/node_modules/**, **/dist/**
No test files found, exiting with code 1
Process exited with code 1
Environment
- OS: windows
- VSCode version: 1.69.0
- Vitest version: 0.17.1
- Vitest plugin version: 0.2.20
Additional context
Using the launch.json config to run tests on the open tests file works as expected. I noticed there appears to be an extra vitest in the command its running in the debug console, which then appears in the filter list. I suspect this is the root of the issue - it's filtering for test files that include "vitest" in their name, which is none of them.
I have the same problem; can you help out with the contents of the launch.json you mentioned above?
Sure thing: it's the one in the docs here.
ok, m fault; how the old saying goes: RTFM 😃
Any progress on this issue?
There is actually a workaround which would be to add vitest to the name of every test file (e.g. vitest file.spec.ts) but there must be a cleaner fix. Also, I am unsure if it is related but watch mode doesn’t seem to be working.
Haven't investigated why but downgrading vitest itself to 0.31.0 fixed it for me. For reference: the latest version of vitest at the moment is 0.31.1
I was getting the same issue No test files found but in my case the filter property was not including the drive path:
My tests were in D:/my-project/test and the filter property was showing /my-project/test (not sure if this was the real issue or it was just display issue)
@countnazgul thx, same issue, and downgrading fixed the problem for me as well
Not sure if Windows is supposed to be supported, but as a workaround I'd try to modify the include option in the vite.config.js file, to match the actual path of the files. Perhaps it has to do with the slashes.
Thanks, downgrading to 0.34.3 fixed this for me too, 0.34.4 does not work at the moment
New version of extension has been released on https://marketplace.visualstudio.com/items?itemName=vitest.explorer. Please try it out, and if the issue still persists, feel free to open a new one.