vscode: "Test result not found" for all tests
I have the same problem as in this already closed issue https://github.com/vitest-dev/vscode/issues/8,the tests are working fine on the terminal (separate or VSCode integrated) but the tests are all failing in the extension:
From testing around I found that without any configuration, the result is this
RUN v0.14.1 E:/repos/project
⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯
FAIL test/code.test.ts [ test/code.test.ts ]
Error: No test suite found in file E:/repos/project/test/code.test.ts
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files 1 failed (1)
Tests no tests
Time 1.84s (in thread 0ms, Infinity%)
And with "vitest.commandLine": "yarn test"
, it actually runs the test, but still displays everything as failed (probably because of the bottom part):
RUN v0.14.1 E:/repos/project
⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯
FAIL test/code.test.ts [ test/code.test.ts ]
TypeError: params.map is not a function
...
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files 1 failed (1)
Tests no tests
Time 1.70s (in thread 0ms, Infinity%)
JSON report written to C:/Users/xxx/AppData/Local/Temp/vitest-report-2v2t12.json
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given no parameters should be defined@2Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given no parameters should instantiate@3Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given parameters should be defined@5Cannot find test file:///e%3A/repos/project/test/code.test.ts/function01 given parameters should work with parameters@6Cannot find test file:///e%3A/repos/project/test/code.test.ts/function02 should be defined@9Cannot find test file:///e%3A/repos/project/test/code.test.ts/function03 should be defined@11
System
- Windows 11 21H2
- VSCode 1.67.2
- Extension v0.2.12
- TypeScript 4.7.3
vite.config.js
import { defineConfig } from 'vite'
export default defineConfig({})
There is also an issue in the vitest repo: https://github.com/vitest-dev/vitest/issues/1407
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 64 (12 by maintainers)
This issue should be reopened as it is far from resolved. This makes using
vitest
not as appealing as it looks initially. Downgrading as solution looks bad.I have the same issue. Such a shame. Have no idea why. Super simple setup. CLI works. VS Code Extension fails:
v0.2.20, Yarn. Changing this setting fixed me, from @leonbloy above:
"vitest.commandLine" : "npx vitest"
I’m facing the same issue but I assume the reason is that we use a monorepo for our frontend and backend. I open vscode with the root directory so there is no package.json or any of the config files in the root directory but instead in one directory deeper (./frontend/package.json etc.)
When I open the project directly in the frontend directory it properly recognizes that there is vitest in place and the tests also run as expected (without the result not found error). I noticed however that it didn’t use the excluded files defined in the vitest.config.ts file so it shows some other test files for playwright as well…
I think it would be nice to be able to configure this in the workspace (e.g. rootDir: “./frontend”) or maybe let the extension check sub directories? (I’m not familiar with how extensions work or if this is even feasible)
Not working in monorepo
same issue, and I found if u run the test again will be ok, hence every time I changed test file need to run test twice?
@btmnk mono repo is not supported yet #6 #13 . As a workaround, you can use it with VSCode workspaces now, thanks to @evanandrewrose .
There’s a common error when running with a nested multi-root workspace (i.e.
root
androot/package/a
are both entrypoints in your VS Code workspace). The Vitest runner will try to run your test with aroot
CWD, and aroot/package/a
CWD simultaneously. Inroot/package/a
, it’ll pick up your config properly & run the test correctly, but inroot
it’ll miss your config, and if your test depends on that it will fail.The extension then picks up on a successful & a failing/misconfigured test result, and gets confused. You can see this if you go to the Vitest section in the Output tab.
The fix is simple (in your
.code-workspace
file):Then restart VS Code. The extension doesn’t pick up on config changes until you do. @zxch3n I think this is the source of most of the errors of this kind, just judging by what people are reporting.
I am getting the same error. I will swich back to Jest until this is fixed
I have this error even though I’m not in a mono repo. Restarting VS Code fix it sometimes. No problems in terminal. package.json has script
"test": "vitest"
and this is my vitest.config.js:@juananmuxed Can you switch to the pre-release version (v0.2.18) to test it again?
@xon52 dynamic test name is not supported yet
Im in a monorepo and found a possible solution: Adding an additional
vitest.config.ts
in root.Here is my structure:
And we are green ✅
I was getting this issue on Windows. I solved it by adding
"vitest.commandLine": "npx vitest"
to my VSCode’s workspace settings.I’m having the same issue,but I solved it!
My global node version is 14. In my project, I temporarily changed the version under the project to 16 by nvm. The extension don’t work.
Then I changed the global node version to be consistent with my project version, and with
"vitest.commandLine": "npx vitest"
,it worked fine.I’m having the same issue as @abarke but downgrading vite to 3.2.6 seems to do nothing. Only VS Code Extension fails.
OK I found the issue and it works for me now. Seems vitest does not like vite v4.x.x
Try forcing it to use v3.x.x
Thanks, @Pustinyak! I added some extra error messages for the situations you listed.
I don’t know why this issue was closed,
I’ve updated to the latests versions (vitest .16.0, vitest extension: 0.2.19 ) and to find the right combination of settings that make this work is a torture.
I would help a lot that the extension has some debug mode or something that spits info to help debugging.
Apart from the versions, there seems to be these factors into play:
OS Windows/Mac/Linux
vitest.commandLine setting
npm/yarn
node in nvm yes/no
vs code terminal (cmd/powershell/bash)
In my case, I have Windows, node with nvm, npm. I start with powershell
I have in my my package json
so that running in my terminal
runs the test as expected (the latter in watch mode)
However the setting
"vitest.commandLine" : "npm run test"
fails with “Test result not found… (etc)” in spite of the test terminal showing the expected output:(it’s strange the stdout | unknown test bit)
and the setting
"vitest.commandLine" : "npm run testw"
(in watch mode) simply hangs everythiong. The test ouptut terminal shows
and the inprogres indicators (spinner, “Running tests messages”) go forever. Restart required.
I try instead
"vitest.commandLine" : "npx vitest"
… and now it works. Don’t know why
Ok. Now I want to switch to my preferred terminal: bash from git in windows.
I follow the recipe here https://stackoverflow.com/questions/42606837/how-do-i-use-bash-on-windows-from-the-visual-studio-code-integrated-terminal/72517865#72517865
And now I’m back to the “Test result not found” error
Maybe works if I add “global”: true ?
@itpropro I published a new version to pre-release (v0.2.15) that fixed the run forever issue. Can you check whether it works now?
Thanks. I’ll look into it
Unfortunately, moving my main project from yarn to pnpm didn’t fix the problem, I still get the same "Test not found’ error, but now I get this one in addition from time to time: