vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
765 stars 87 forks source link

Extension fails to fetch dynamically imported module #544

Open dlims opened 5 days ago

dlims commented 5 days ago

Describe the bug

Tests launched from test explorer in browser mode fail to load extension module.

Reproduction

Just trying to run a test in browser mode from test explorer produces this error:

TypeError: Failed to fetch dynamically imported module: http://localhost:63315/@fs/C:/Users/dlore/.vscode/extensions/vitest.explorer-1.8.1/dist/setupFile.mjs?import&browserv=1732438481928

Output

[11:01:08 AM] Initiating deferred test run [INFO 11:01:08 AM] Running 1 file(s): src/core/unit-test-browser/VitestBrowserExample.spec.browser.ts [11:01:08 AM] The runner is starting because tests src/core/unit-test-browser/VitestBrowserExample.spec.browser.ts were started due to a file change [INFO 11:01:08 AM] [Worker] The request url "C:/Users/dlore/.vscode/extensions/vitest.explorer-1.8.1/dist/setupFile.mjs" is outside of Vite serving allow list [Error 11:01:08 AM] Error in C:/Users/dlore/Github/bauhaus_master/src/core/unit-test-browser/VitestBrowserExample.spec.browser.ts TypeError: Failed to fetch dynamically imported module: http://localhost:63315/@fs/C:/Users/dlore/.vscode/extensions/vitest.explorer-1.8.1/dist/setupFile.mjs?import&browserv=1732615268915 [11:01:08 AM] Marking "VitestBrowserExample.spec.browser.ts [browser]" as failed with 1 errors [11:01:08 AM] Marking "VitestBrowserExample.spec.browser.ts [browser]" as failed with 1 errors [11:01:08 AM] Ending test run src/core/unit-test-browser/VitestBrowserExample.spec.browser.ts [11:01:09 AM] [VSCODE] Ignoring file: node_modules.vite\vitest\bcfb0f9579ecec702e2da1067b249218\results.json

Version

Vitest Explorer: 1.8.1 Vite: 5.4.10 Vitest: 2.1.5

Validations

dlims commented 5 days ago

The same test launched from script works properly

hoisel commented 4 days ago

+1

PPDEMOone commented 3 days ago

I have the same problem.

sheremet-va commented 3 days ago

The "Output" field in this issue is not correct. It prints much more information, please don't crop it. Please read what the issue template says:

The content of "Output" tab. You can open this tab by typing "> Show Vitest Output Channel" in a search bar or pressing "See error" on an error message if there is one. Your issue will be closed if you do not provide the full output (starting with Vitest version) - do not remove any "irrelevant" information - the maintainer will decide if it is valuable or not.

github-actions[bot] commented 3 days ago

Hello @dlims. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

sheremet-va commented 3 days ago

I will add "needs reproduction" label, but more output should be enough. I also need to know Vite and Vitest versions.

dlims commented 3 days ago

I will add "needs reproduction" label, but more output should be enough. I also need to know Vite and Vitest versions.

I've added requested info.

kayahr commented 2 days ago

Maybe this is some incompatibility to latest vitest or vitest/browser? I suddenly have the same problem in all my projects, so I tested it in a small demo project I created for a past issue:

https://github.com/kayahr/vitest-bugs-4

This demo project uses vitest 2.1.4 and I can't reproduce the problem there. But when I update vitest and vitest-browser dependency to 2.1.6 and restart vscode (or reload the tests) then I get the error:

image

Downgrading to 2.1.4 fixes the problem. With 2.1.5 it also doesn't work so I guess the problem was introduced in vitest 2.1.5. Or vitest/browser 2.1.5 (as only the browser tests are affected)