You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tests should run, React Babel transform configured correctly for test environment
Actual Behavior
> node_modules/.bin/vitest
Error: [BABEL] /tmp/my-remix-app/app/demo.test.tsx: React Refresh Babel transform should only be enabled in development environment. Instead, the environment is: "test". If you want to override this check, pass {skipEnvCheck: true} as plugin options. (While processing: "/tmp/my-remix-app/node_modules/react-refresh/babel.js")
It appears that this occurs due to the remix vite plugin including the React Refresh Babel transform when not in production, but the transform complains about being included in prod.
The text was updated successfully, but these errors were encountered:
I think, for the purpose of unit test, it might not be even necessarily to use remix plugin.
So, one workaround could be to disable plugin when running on vitest (cf. https://vitest.dev/config/#configuration) e.g. by
exportdefaultdefineConfig({plugins: [!process.env.VITEST&&remix(),// filter it out based on VITEST env vartsconfigPaths()],test: {environment: 'jsdom'}});
Maybe one change which can be done on remix plugin side is that, as indicated by the error message, remix could set {skipEnvCheck: true} here to allowing using remix plugin regardless of environment:
Thanks @hi-ogawa for your solution with process.env.VITEST - I hadn't tested skipping the remix plugin based on my assumption that it was required for JSX transforms, but I'm very pleased to have found out I was wrong. It works well for me with the configuration you've suggested.
I agree that you probably don't want to run the Remix plugin in your tests, but either way, this error message will be suppressed in the next release thanks to #7980.
What version of Remix are you using?
2.2.0
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
Either a), run the reproduction here: https://github.com/adam1658/remix-unstable-vite-vitest-reproduction,
or follow the below instructions
unstable-vite
template:npx create-remix@latest --template remix-run/remix/templates/unstable-vite
.cd my-remix-app
npm install -D vitest jsdom @testing-library/react
export default defineConfig({ plugins: [remix(), tsconfigPaths()], + test: { environment: 'jsdom' } });
node_modules/.bin/vitest
Expected Behavior
Tests should run, React Babel transform configured correctly for test environment
Actual Behavior
It appears that this occurs due to the remix vite plugin including the React Refresh Babel transform when not in production, but the transform complains about being included in prod.
The text was updated successfully, but these errors were encountered: