Error: [vite-plugin-ssr@0.4.43][Wrong Usage][`navigate(url)`] Something is wrong with your environment (it loads the wrong `vite-plugin-ssr/client/router` entry). This may be happening if you use Jest or Babel. Open a new GitHub issue to discuss a solution.
See original GitHub issueQuestion / Discussion
After adding import { navigate } from 'vite-plugin-ssr/client/router'
to one of my components I now get the following error when trying to test it:
Error: [vite-plugin-ssr@0.4.43][Wrong Usage][`navigate(url)`] Something is wrong with your environment (it loads the wrong `vite-plugin-ssr/client/router` entry). This may be happening if you use Jest or Babel. Open a new GitHub issue to discuss a solution.
I am using React Testing Library to render and test my component. I am not using Jest or Babel.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
[Bug]: Module Import Stack Trace sometimes broken · Issue ...
Version 29.0.3 Steps to reproduce Clone this repo: git clone https://github.com/smcenlly/jest-stack-trace-issue Install dependencies npm install From the ...
Read more >Vite compatible Jest preset · Issue #1149 · vitejs/vite - GitHub
I 'm migrating a large codebase to Vue 3 + Vite. The project contains tests I'd like to reuse. But due to the...
Read more >Tests Fail Using Basic Configuration (React Native/TypeScript ...
Ultimately - I just wanted to move to SWC to get faster, more stable, and ultimately the most performant tests I can run)....
Read more >jest: Test suite failed to run, TypeError: Cannot read property ...
we were using jest from unit testing in react-native. It was working well. We just deleted npm and installed it again and then...
Read more >Requires Babel "^7.0.0-0", but was loaded with "6.26.3". #6913
Bug Report I get the following message when trying to run tests. None of the solutions in the documentation or other issues work....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Let me know if you need the fix to be released sooner rather than later.
Also, in case your employer has the financial capabilities: https://github.com/sponsors/brillout. Sponsors make a huge difference and allow me to further work on VPS.
From my investigations it looks like it’s: https://github.com/brillout/vite-plugin-ssr/blob/8f8cab47c2a229ab6161e8bb01d3fda447602ceb/vite-plugin-ssr/node/client/router.ts#L6
In tests this is being evaluated when the function is imported and as the tests run in a jsdom environment under Node it fails the assertion. If I remove this assertion my tests then run as expected. However, in a component which uses
navigate
I now get:I’m not sure what the solution is. I think I need some guidance on how testing should be done.
Fixed my test by adding: