-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[charts][ESM] @mui/x-charts
does not work with jest
#11568
Comments
@mui/x-charts
does not work with jest
@alexfauquette it seems https://github.com/d3/d3-scale/blob/d6904a4bde09e16005e0ad8ca3e25b10ce54fa0d/package.json#L21 |
Seems similar to #9826 (comment) I also found other issues on this topic, but did not manage to fix the reproduction example with them |
Hi @Notalifeform could you try using this fix: d3/d3-interpolate#96 (comment) please? |
Hi @michelengelen , Thanks for getting back to me. I did try to transpile the module as in this brach, but it did not help: https://github.com/rocsys/mui-x-charts-jest-issue-minimal-reproduction/pull/1/files moving the config to package.json did not help either: https://github.com/rocsys/mui-x-charts-jest-issue-minimal-reproduction/pull/2/files |
Hey @Notalifeform ... Thanks for testing that. It's a shame it wasn't that easy of a fix. |
I'm adding test on the charts We have similar (not exactly the same) issue to add test on our side on charts. I assume solving #11551 would help |
@alexfauquette I did assign this to you to keep track of it. Could you comment here when the addition of tests provides a solution for this? Thanks! 🙇🏼 |
How I fixed the issue:
|
@mui/x-charts
does not work with jest@mui/x-charts
does not work with jest
I had the same issue and adding this mock: jest.mock("@mui/x-charts", () => ({
BarChart: jest.fn().mockImplementation(({ children }) => children)
})); to the tests solved it |
This in my jest config got me going again, but obviously it's alot
|
This comment was marked as resolved.
This comment was marked as resolved.
I just updated to v7 charts had to add a few more. add "robust-predicates|delaunator" |
Dear Team and @alexfauquette The above solution resolved the export token issue encountered while running Jest test cases for my project. However, one component in my project extensively uses the Warning React.jsx type is invalid --expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. and also console.warn
console.error component:
at div |
Dear @cstephens-cni @Notalifeform and @oliviertassinari and @alexfauquette and @michelengelen, Could anyone in this thread please reply to help me with this? I am stuck in the middle. Thanks. |
@TVDharma Without a minimal reproduction example, it's hard to say why the workaround does not work for you |
Config files changes to work with d3-scale (mui/mui-x#11568)
The d3 bug was resolved, but I encounter another bug.. Just found out the resolve method.. following @cstephens-cni
|
Still facing the issue with BarChart. `SyntaxError: Unexpected token 'export'
here is my jest config
|
We have the same issue with ChartsAxis, as there is an export in ESM module
None of the given solutions did solve it 😔 |
@konrazem @onkartme Could you test if by using the following package version in your
Those are preview of #13608 Edit I edited this message to update the commit used. The original ones were broken due to a regression in the PR. Please do not consider the feedback following this message |
@alexfauquette thank you for taking care of this issue. Unfortunatelly it didn't help. The only solution that is working right now for as is to add this conditions to our jest.config.js to moduleNameMapper
|
@konrazem could you share a reproduction of your issue? Because your issue is probably different than the one in this issue, because using the PR commit solves the intial reproduction |
hey @alexfauquette unfortunately this didn't solve the issue. The issue still there. :( |
My bad, I double-checked and it seems the fix is broken. My apologies giving you broken links. Could you try again with the last working one
This one is fixing the reproduction in the initial issue |
This comment was marked as resolved.
This comment was marked as resolved.
I think it is strongly related to this issue.As I mentioned, we were able to fix our tests with this solution
|
@https://github.com/alexfauquette using
doesnt fix it for me ,. i get
|
@sterlingdcs-damian You copied the one with Could you try with either
|
This is where mui/material-ui#42984 would provide a bit nicer UX/DX for users in such cases with the ability to reference packages by GH PR number. 🤔 |
For users, yes but not for developers. Being able to retry the build of previous commits helped me to narrow down which commit introduced the regression |
You can use both identifiers. 😉 |
@Notalifeform: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
The fix will be available in the next release at the end of the week |
The problem in depth 🔍
Link to example: https://github.com/rocsys/mui-x-charts-jest-issue-minimal-reproduction/
Steps:
yarn test --watchAll=false
jest will fail with
I attempted to transpile the mui/x-chart module, but it does not seem to work?
https://github.com/rocsys/mui-x-charts-jest-issue-minimal-reproduction/tree/feature/attempt-to-transpile
our project uses without any issue:
but jest breaks when adding
Your environment 🌎
npx @mui/envinfo
Contextn
Related issue: jestjs/jest#9430
Search keywords: x-charts jest
Order ID: 70120
The text was updated successfully, but these errors were encountered: