-
Notifications
You must be signed in to change notification settings - Fork 29
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
react: TypeError during tests with Vitest + Recoil #203
Comments
Upgraded to [email protected] but the end result is the same :( |
Hi @theohagos can you create a basic example with that shows this issue please? |
Hello @gioboa, thanks for your response. The project is internal to JPMorgan, so afraid won't be able to post an exact replica but I have narrowed it down to recoiljs that is causing this error. I am also using nx workspace with rspack module federation to create remote MFEs. These apps also use recoil with vitest and the tests run successfully without this error. |
So the problem is the combination mf/vite + recoiljs + vitest, right? |
Hello @gioboa, Yes exactly that. Remove recoiljs test passes, add recoiljs back and then test throws above error. But there is no error when running the app, it works, it consumes remotes and no issues there. Funnily enough I have the opposite problem with originjs/vite-plugin-federation, that is what led me to this plugin. With origin, tests pass but the app fails with this error Cannot read properties of null (reading 'useState'), looks like it is loading multiple version of react. |
You can share react dep to avoid that problem, but idk if you can do it with that plugin |
Have you tried with different Node versions? |
I have the same error when running Vitest + mf/vite My versions: I'm not using Recoil. Tested with node versions 16, 18 and 20. All of them outputs the same error message: I tested using vi.doMock and |
Hi @gioboa, so it looks like it may not be specific to recoiljs since @deizianens is ALSO facing the same error without using recoiljs? |
Hi @deizianens , can you create a basic example that reproduce the issue please? |
Sure @gioboa |
It is happening to me too, my tests were working with |
When you were using originjs/vite-plugin-federation was there any additional setup or mocking you had to do to get the tests to pass? I have tried both and both seem to have issues with the tests. I'm getting the same error. Unfortunately, it is for my employer, and can not share specifics |
@saraiba33 I haven't changed anything, but what I did to skip this issue was to avoid federation when running tests, just doing the following in vite.config:
|
I tested the @deizianens example https://github.com/deizianens/mfe-vite |
I get the same error when I include a |
@module-federation/[email protected]
[email protected],
[email protected]
When running test the following error is thrown
TypeError: Method Promise.prototype.then called on incompatible receiver [object Module]
The text was updated successfully, but these errors were encountered: