-
Notifications
You must be signed in to change notification settings - Fork 293
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
Testing with Vitest #666
Comments
Yep I'm seeing the exact same thing. My configuration is as follows:
|
Same problem. Also tried to add babel plugin import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
export default defineConfig({
plugins: [
vanillaExtractPlugin(),
react({
babel: {
plugins: ["@vanilla-extract/babel-plugin"],
},
}),
],
test: {
globals: true,
environment: "jsdom",
setupFiles: "setupTests.ts",
},
}); |
Hey All. I ran into this a few weeks ago, it was a pain to debug. The issue is with some code being run in ESM and some in CJS so the file scopes stuff is split across 2 separate modules and therefore cannot see each-others local variables. Long story short you need to include the following in your Vite config: {
// ...
test {
deps: {
fallbackCJS: true,
}
}
} https://vitest.dev/config/#deps See fixed fork here: https://stackblitz.com/edit/vitejs-vite-1fmagr?file=vite.config.ts |
Thank you 👍 |
It looks to be related to this issue: vitest-dev/vitest#747 Similar to the comment in that thread one solution is to delete which interferes with the module resolution defined at the top-level |
@markdalgleish Might be worth adding @domosedov solution to the docs? It does print this error message by default with vitest. |
This has been properly fixed with #833 |
That's great. It's not yet in any release, right? Because when removing the code, I still see the old behavior. |
@swernerx it was released in @vanilla-extract/[email protected], working for me. |
Interesting, I am on 1.9.2, and it is definitely not working without the |
Hello, any help how test vanilla-extract with Vitest?
Demo: Stackblitz
i have an error with
npm run test
The text was updated successfully, but these errors were encountered: