Closed benparks1976 closed 3 months ago
Hey @benparks1976 ... my colleague @JCQuintas noticed that you were using the old syntax. If you change the code in your example to this it should work:
import React from "react";
import Demo from "../demo";
import { render } from "@testing-library/react";
describe("when rendering the data grid", () => {
it("should render the table columns", async () => {
const {findAllByRole} = render(<Demo/>)
const headers = await findAllByRole("columnheader")!;
expect(headers[1].textContent).toBe("Serial number");
expect(headers[2].textContent).toBe("Model name");
});
})
Could you try that please?
Hi, thanks for the follow up. I tried your suggestion and I still got the same issue:
It does work on my machine:
Did you try a fresh install?
Hi @benparks1976, the tests are green on my side with the example code you provided. I've noticed you are using node 14
, which doesn't support the array.at()
function. I would suggest upgrading your node to a more recent version, at
is available from 16.6
.
Otherwise you could also add a polyfill. eg: https://www.npmjs.com/package/array.prototype.at
Thanks @JCQuintas, this is the problem. Thanks all for your help.
Closing...
:warning: This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.
@benparks1976: 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.
I am using node 18 and still having the above problem, please help me
Steps to reproduce
As this problem occurs in the react test I'm not able to provide a live link. Instead I have attached react project including a test reproduces the issue. I hope this sufficient. mui-repro.zip
Steps.
Current behavior
When the component is rendered by the react testing framework the following error is shown:
Error: Uncaught [TypeError: apiRef.current.state.rows.dataRowIds.at is not a function]
Expected behavior
The error should not occur when rendering the MUI data grid component.
When the same test is run with Mui data grid version 6.9.2 the problem does not occur.
Context
Write unit tests for our components that use Mui data grid 7.6.1.
Your environment
System: OS: Windows 11 10.0.22631 Binaries: Node: 14.20.1 - C:\Program Files\nodejs\node.EXE npm: 6.14.17 - C:\Program Files\nodejs\npm.CMD pnpm: Not Found Browsers: Chrome: Not Found Edge: Chromium (125.0.2535.79)npx @mui/envinfo
Search keywords: react testing library with mui data grid