-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[data grid] DataGrid fails to render in react-test-renderer #6582
Comments
Hey @sap-dshapovalov |
@cherniavskii sure thing, please see this repo: If you run npm test there, you should see the issue |
According to facebook/react#7740 (comment), diff --git a/packages/grid/x-data-grid/src/components/GridAutoSizer.tsx b/packages/grid/x-data-grid/src/components/GridAutoSizer.tsx
index 1955042a6..52ea0c29c 100644
--- a/packages/grid/x-data-grid/src/components/GridAutoSizer.tsx
+++ b/packages/grid/x-data-grid/src/components/GridAutoSizer.tsx
@@ -116,7 +116,7 @@ const GridAutoSizer = React.forwardRef<HTMLDivElement, AutoSizerProps>(function
useEnhancedEffect(() => {
parentElement.current = rootRef.current!.parentElement;
- if (!parentElement) {
+ if (!parentElement.current) {
return undefined;
} Then, pass a it('should work with react-test-renderer', () => {
const testRenderer = TestRenderer.create(
<div style={{ width: 300, height: 500 }}>
<DataGrid {...baselineProps} hideFooter />
</div>,
{
createNodeMock: (node) => {
return document.createElement(node.type);
},
},
);
}); It will work but note that no row will be rendered—because the mocked node has no dimensions—, so I don't know if it's worth to invest in snapshot testing. Given this limitation, I would say to continue using Related to #1151 |
Duplicates
Latest version
Current behavior 😯
Please, see the following code snippet:
First test renders without errors, second test fails to render with various null reference errors:
Expected behavior 🤔
Both tests should render DataGrid successfully
Steps to reproduce 🕹
No response
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: