Open borisyordanov opened 3 weeks ago
If I modify the @refinedev/mui/dist/index.mjs
in my node_modules
to import import Box from "@mui/material/Box/index.js";
instead of import Box from "@mui/material/Box
the import is resolved.
Before
After
@aliemir I managed to get the tests running https://vitest.dev/config/#server-deps-inline
Hey @borisyordanov thanks! It seems that could fix the problem, but we need to check possible side-effects for this one. We'll get back to you next week.
Hey @borisyordanov, thank you for opening the issue and writing an explanation for your case 🙏 Adding a documentation section for vitest/jest testing and adding an example will be great for many users imho 🤔
Thank you for sharing your solution for the @refinedev/mui
+ vitest
error 🙏 This is related with how we do imports from @mui/*
packages, I'm not sure if there's any way that works for every platform in both ESM and CJS but maybe we can transform these imports for ESM and CJS bundles to make sure the imports are pointing to correct files with correct shape 🚀
Same issue also occurs when using Material UI with Remix in SPA mode (https://github.com/refinedev/refine/issues/6007). Unfortunately, Material UI has some issues with ESM exports (https://github.com/mui/material-ui/issues/30671), until they resolve those issues we will try to have workaround to get past them in our @refinedev/mui
package.
Documentation issue
The testing page does not have any instructions on tesing with partially-implemented browser environment, like jsdom
Describe the thing to improve
Apps built with refine can contain custom logic that needs to be tested. browser tests (e.g cypress/playwright) are a great way to make certain assertions but for other cases unit and integration tests headless testing (e.g vitest/jest) are much more apt.
When I include the![image](https://github.com/refinedev/refine/assets/12392666/613ae7ca-be76-4944-bd18-591c9886400b)
Refine
provider in a vitest environment tests start crashing with this errorThe lack of testing documentation means it's very difficult to make the tests run.
Describe the solution (optional)
https://github.com/refinedev/refine/tree/master/examples contains examples of a unit testing setup with vitest and jest and react testing library
Context
I'm working in a monorepo, built with https://nx.dev/ and pnpm workspaces
tsconfig.app.json tsconfig.json tsconfig.spec.json