Skip to content
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

Add support for react-admin v5 #572

Merged
merged 18 commits into from
Jul 11, 2024
Merged
2 changes: 2 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const config: JestConfigWithTsJest = {
moduleNameMapper: {
'^(\\.{1,2}/.*/llhttp\\.wasm\\.js)$': '$1',
'^(\\.{1,2}/.*)\\.js$': '$1',
'^@tanstack/react-query$':
'<rootDir>/node_modules/@tanstack/react-query/build/modern/index.cjs',
Comment on lines +12 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, Jest resolved imports to @tanstack/react-query to the ESM code when imported from the test file, and to the CJS code when imported from ra-core. This caused the issue about QueryClient because the references to the context object were not equal.

This line forces the resolution to the CJS code all the time, which solves the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it a problem react-admin users may be facing, too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it could be, if they are using Jest with NODE_OPTIONS=--experimental-vm-modules. But I'm not sure it's react-admin's responsibility to document this, as this rather looks like a Jest bug to me...

},
transform: {
'^.+\\.tsx?$': [
Expand Down