Closed kwojcik closed 1 month ago
There should be no new dependencies optimized
logs at all for Vitest (or any Vite-based testing framework) to work correctly. Having @vitest
ones is a bug in Vitest. The react one is interesting, maybe we should add well-known dependencies ourselves.
For now, you can add them to your config manually:
export default defineConfig({
optimizeDeps: {
include: ['react/jsx-dev-runtime'],
exclude: ['@vitest/coverage-istanbul'],
}
})
I guess this doesn't show up in our own tests or ecosystem ci due to locally linked packages. It would be great to be able to replicate this issue in our tests at least. 🤔
@httpete maybe this is what you were experiencing in https://github.com/vitest-dev/vitest/issues/5615?
The @vitest
packages should be fixed by #6445
We also now print the warning that Vitest doesn't expect dependencies to be optimized.
Regarding react - please, use @vitejs/plugin-react
if you use react
in your project. It adds the jsx-transform to include
automatically.
Describe the bug
Using browser mode and either v8 or istanbul coverage, the test run fails the first time after installing node_modules with error
Failed to fetch dynamically imported module: http://localhost:5173/@id/@vitest/coverage-v8/browser?import
. This is currently blocking me from upgrading because tests fail 100% of the time in CI since it's a fresh node_modules.AFAICT, this was introduced in 2.1.0-beta.1. It works fine in 2.0.5, but look at how basic.test.tsx gets run twice (see below)
Reproduction
branch: https://github.com/kwojcik/vitestsourcemapbug/tree/coverageCrashRepro
System Info