Open sorinpav opened 6 months ago
@sorinpav Which version was it working for you?
Hi @oliviertassinari! Thanks for answering :).
I upgraded the following packages:
Tests were all working pre-upgrade.
Hope this helps. Let me know if you need anything more from me, thanks!
I see #8672 as the origin of this issue. It's pretty much the same as #1151.
It seems that we have a few options:
IntersectionObserver
but maybe it's weird it's soon going to be in Material UI v6 range of browser support.IntersectionObserver
either. I would vote for Option 1. This seems to be the most pragmatic, it's not pure but it's very effective.
I see - thanks for investigating this. Not quite the gotcha I was expecting. I had hoped that it's something easier to solve. I'll leave this open to see if anyone comes up with a better solution.
@oliviertassinari gentle ping on the above ☝🏼
I don't quite understand your first suggestion, could you please expand on that?
https://github.com/mui/material-ui/blob/2cd2c1f18facbabf1e8b0a4bbb0de80ac98c7d96/packages/mui-material/src/Tabs/Tabs.js#L681 makes sense to me, until jsdom supports it. I mean, who would want to test this in jsdom in the first place?
@oliviertassinari thanks! Earliest I can test if that would be working is on Tuesday. I'll report back here.
Actually, it's also related to https://github.com/mui/mui-x/issues/1151. Having it work outside of the box, is one approach. Another is to have developers setup polyfills in their environment.
Apologies, did not get around to trying this out yet. I will try soon. However, what I'm about to try is only a workaround technically, so I would say this issue should stay open until a proper solution is advised. Thanks!
Adding a jest mock for IntersectionObserver
in the tests that are failing has fixed the error in my case
beforeEach(() => {
const mockIntersectionObserver = jest.fn();
mockIntersectionObserver.mockReturnValue({
observe: () => null,
unobserve: () => null,
disconnect: () => null,
});
window.IntersectionObserver = mockIntersectionObserver;
});
Steps to reproduce
No response
Current behavior
The React project works fine, as far as I can see. I can't say that about the React Testing Library tests as well. When running the previously passing x-data-grid-premium tests, now we get errors about:
Note: We do not directly use
IntersectionObserver
in our codebase at all. It is complaining about theIntersectionObserver
used insideuseGridInfiniteLoader.js
, which is coming directly from the data grid package. If I was to have a guess, I would think there's a polyfill that's missing after the upgrade...?Expected behavior
Tests should pass - React project is working as expected, so tests should pass as well.
Context
No response
Your environment
``` System: OS: Windows 10 10.0.19045 Binaries: Node: 20.9.0 - C:\Program Files\nodejs\node.EXE npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD pnpm: Not Found Browsers: Chrome: Not Found Edge: Spartan (44.19041.1266.0), Chromium (123.0.2420.97) npmPackages: @emotion/react: ^11.11.3 => 11.11.3 @emotion/styled: ^11.11.0 => 11.11.0 @mui/base: 5.0.0-beta.29 @mui/core-downloads-tracker: 5.15.16 @mui/icons-material: ^5.15.1 => 5.15.2 @mui/lab: ^5.0.0-alpha.157 => 5.0.0-alpha.158 @mui/material: ^5.15.16 => 5.15.16 @mui/private-theming: 5.15.14 @mui/styled-engine: 5.15.14 @mui/system: 5.15.15 @mui/types: 7.2.14 @mui/utils: 5.15.14 @mui/x-data-grid: ^7.3.2 => 7.3.2 @mui/x-data-grid-premium: ^7.3.2 => 7.3.2 @mui/x-data-grid-pro: 7.3.2 @mui/x-date-pickers: ^5.0.15 => 5.0.20 @mui/x-license: 7.2.0 @types/react: 17.0.3 react: ^18.2.0 => 18.2.0 react-dom: ^18.2.0 => 18.2.0 typescript: ^5.4.5 => 5.4.5 ```npx @mui/envinfo
``` We use React Testing Library: "@testing-library/dom": "^9.3.3", "@testing-library/jest-dom": "^6.1.5", "@testing-library/react": "^14.1.2", "@testing-library/user-event": "^14.5.2", ``` **Search keywords**: IntersectionObserver **Order ID**: 77486Testing library used: