-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Remix and Vitest: "$RefreshSig$ is not defined" #8094
Comments
Would you check if it works by disabling remix plugin like in #7918 (comment)? |
Also hit this. There is some additonal config complexity when disabling the remix plugin in test mode. You need to manually load the env vars, more context #7934 (comment) I was hoping to remove this work around when 2.3.0 came out but it's still needed in test mode as you can't use the plugin. |
@john-griffin Would you elaborate your current workaround? I'm also hoping if there is a way to reduce these frictions out-of-the-box when integrating vite remix plugin, but at this stage, I think it's important to gather use cases and understand what's the actual issues before trying to come up with a general solution. |
@hi-ogawa this is a new remix app started with the vite integration from scratch. We followed the @markdalgleish suggestion here #7934 (comment) that loads the env vars in. We are also following his suggestion here #7958 (comment) around use of process.env vs import.meta.env |
@john-griffin Thanks for reporting back! I think I understand the clumsiness you are experiencing, but it would be still helpful if you can provide an exact code snippet of what you do so that we can understand the problems better. From what I can guess, I made an example repo to show how remix users can handle Here is how //
// vite.config.ts
//
import { unstable_vitePlugin as remix } from "@remix-run/dev";
import { defineConfig, loadEnv } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
export default defineConfig({
plugins: [
// disable remix plugin for vitest
!process.env.VITEST && remix(),
tsconfigPaths(),
],
test: {
environment: "happy-dom",
// load variable without "VITE_" prefix in ".env.test"
env: loadEnv("test", process.cwd(), ""),
},
}); My current view is that it's fine for remix to see this as a limitation of Vitest (which in turn says it's a limitation of Vite). |
@hi-ogawa thank you! That config works great and is exactly what we needed - much cleaner more targeted approach. Yes some documentation around this would be very helpful! |
We now have docs for Storybook and Vitest integration |
Reproduction
Set up Vitest.
Set up a test file with the example from the Remix docs:
System Info
Used Package Manager
yarn
Expected Behavior
The example test file will pass the test.
Actual Behavior
This error is thrown in the console:
The text was updated successfully, but these errors were encountered: