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

Test result not found error when running any test #8

Closed
georgemickleburgh opened this issue Mar 30, 2022 · 4 comments
Closed

Test result not found error when running any test #8

georgemickleburgh opened this issue Mar 30, 2022 · 4 comments

Comments

@georgemickleburgh
Copy link
Contributor

Hi, I'm trying to get the extension to run on Windows and I seem to be getting the same "Test result not found" error when running any of the tests.

I did a debug run of a test to see what was running and the output was:

"E:\Program Files\nodejs\node.exe" .\node_modules\vitest\vitest.mjs run /Users/George/frontend-v8/src/composables/__tests__/auth.test.ts --testNamePattern "auth composable should start with a null current user and account" --reporter=default --reporter=json --outputFile C:\Users\George\AppData\Local\Temp\vitest-report-b18l2.json

 RUN  v0.8.0 c:/Users/George/frontend-v8

Could not read source map for file:///c:/Users/George/frontend-v8/@vite/env: ENOENT: no such file or directory, open 'c:\Users\George\frontend-v8\@vite\env.mjs.map'
⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/composables/__tests__/auth.test.ts [ src/composables/__tests__/auth.test.ts ]

Error: No test suite found in file c:/Users/George/frontend-v8/src/composables/__tests__/auth.test.test

 ❯ runFiles node_modules/vitest/dist/entry.js:870:18
 ❯ startTests node_modules/vitest/dist/entry.js:880:9
 ❯ async node_modules/vitest/dist/entry.js:907:7
 ❯ async withEnv node_modules/vitest/dist/entry.js:504:5
 ❯ async run node_modules/vitest/dist/entry.js:906:5
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Test Files  1 failed (1)
     Tests  no tests
      Time  5.98s (in thread 0ms, Infinity%)
JSON report written to C:/Users/George/AppData/Local/Temp/vitest-report-b18l2.json
Process exited with code 1

If I run the exact same command within from the Terminal inside VSCode I get the expected result:

"E:\Program Files\nodejs\node.exe" .\node_modules\vitest\vitest.mjs run /Users/George/frontend-v8/src/composables/__tests__/auth.test.ts --testNamePattern "auth composable should start with a null current user and account" --reporter=default --reporter=json --outputFile C:\Users\George\AppData\Local\Temp\vitest-report-b18l2.json

 RUN  v0.8.0 C:/Users/George/frontend-v8

 √ src/composables/__tests__/auth.test.ts (5)

Test Files  1 passed (1)
     Tests  1 passed | 4 skipped (5)
      Time  2.90s (in thread 3ms, 114416.96%)

JSON report written to C:/Users/George/AppData/Local/Temp/vitest-report-b18l2.json

I'm not sure the if the source map error is relevant (seems to be missing the node_modules in the path), but it doesn't seem to be finding any tests. I get the same error for each test if I try and do the global run.

@zxch3n
Copy link
Member

zxch3n commented Mar 30, 2022

Thanks. The source map error is not relevant.

I don't have clues about how to fix this issue yet. I guess this might be related to the default shell child_process.spawn uses (with the shell option on).

@georgemickleburgh
Copy link
Contributor Author

Thanks for the hint - I managed to get it working locally with some hacking around.

I found that if I use shell: 'powershell' then my logging was showing that the tests were running, but it was still throwing the "Test result not found" error.

I followed the error down and noticed that a couple of the file paths didn't match up (only on Windows). The pathToFile Map in runHandler.ts appears to be setting the paths as c:/..., but fileResult.name uses an uppercase C:/..., which means that the getTestCaseId always returns undefined.

I put in a hack-y fileResult.name.replace('C:', 'c:') and all of the tests worked correctly.

I don't have any experience with vscode extensions, but I can try and work out a proper fix and submit a PR (unless you have a better idea of what's going on now) 🙂

@zxch3n
Copy link
Member

zxch3n commented Mar 30, 2022

Great! I'm looking forward to your PR

@itpropro
Copy link

itpropro commented Jun 8, 2022

I have the same issue @zxch3n, the tests are working fine on the terminal (separate or VSCode integrated) but the tests are all failing in the extension:
image
From testing around I found that it works when I configure "vitest.commandLine": "yarn test" in the user settings, but if I configure the same exact entry in the workspace settings, all the tests fail again.
There is also an issue in the vitest repo:
vitest-dev/vitest#1407

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants