-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Datatable broken under vitest / react-testing-library tests #626
Comments
Please let me know and/or close the issue if correctly importing the styles solves the problem. |
@icflorescu First of all, thanks for taking time for my issue. I am working with your table for a long time and I'm fully aware of the importance of importing the css files. I have added I still get the same issue. So this seems not to be an issue with my code. I'm almost sure you did build this library using dom manipulation that are not supported by jsDom, causing the tests to fail. |
We are having the same issue in our project. The table always renders in tests showing the No Records message. Are there any examples of how to test the DataTable with |
Hi @icflorescu, Im facing the same issue in tests only, not problem with the build. When debugging, props are delivered well to the DataTable component but still show 'No records' been trying even with waitFor, finds... etc... nothing. Is this project tested? I could not find them. 🤔 |
Yeah, I've just spent two hours on this. I'm trying to write a dead simple test that data is rendered when provided. No dice. |
I'm running into this issue as well. At this point, I'd love to see a working example of testing a dataTable with rtl |
I've run into a similar issue. By default, Vitest doesn't process CSS files, so you must enable that by specifying But there's still a problem: the table rows are all blank: (I use Vitest Preview to preview the test screen in the browser) If I add |
I've figured it out. This is the line that prevents the columns from showing up:
useMediaQueryStringOrFunction uses the Mantine @Aram1d I've created a fork of your repo with these fixes here: https://github.com/jedusei/mantine-datatable-rtl-issue |
@icflorescu I'm not sure that modifying the media query matcher to always return true is the best solution. That may affect other components that rely on I think it would be better to change this line:
to something like this: |
I'm facing the same issue, however I was able to get working by mocking the jest.mock('@mantine/hooks', () => ({
...jest.requireActual('@mantine/hooks'),
useMediaQuery: () => jest.fn().mockReturnValue(true),
})) |
Describe the bug
records
prop is correctly populated, thenoRecords
message remains, and rows appears unpopulated.To Reproduce
Steps to reproduce the behavior:
very small repo with one table and one test to reproduce the issue: repo
Expected behavior
I would expect to be able to get the rows with their data on my RTL tests so I can make assertions
Screenshots
The real table in the repo I linked:
What's rendered on my RTL tests:
Note the empty
<tr>
tags.Desktop (please complete the following information):
Kubuntu 24.04 LTS x86_64
with6.8.0-39-generic
kernelAdditional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: