-
-
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
Test failures in v5.0.1 #2945
Comments
The virtualization engine was completely rewritten, I suppose that is main reason for your tests to fail. Without knowing how is your test environment we can't provide clear guidance to make them to pass. Are you using jsdom or running in a real browser (e.g. Chrome)? Do they pass using |
Hi, thx for the quick feedback. Tests are run in jsdom, and using You mean rewritten as in "you'd have to throw in a few waitFor() to find the columns"? |
About our test setup, a typical test case using a DataGrid does
|
The
Probably there's the problem. The virtualization doesn't relay on Also, if you managed to share a test case (e.g. in a GitHub Gist or repo) I could take a better look to see what's going on. |
Thx, I'll try that first and if it doesn't fix it I'll setup a real case in a repo |
@m4theushw Thx for your help, that was it for 90% of the failures. The remaining failures were due to the columns being recycled in the DOM, and not removed. I suppose these are side-effects of the changes you mention above. For the record, in case someone else get similar failures in the future, in jsdom: Object.defineProperties(Element.prototype, {
clientWidth: { get: () => /* your width here */ },
clientHeight: { get: () => /* your height here */ }
}); |
If we have other feedbacks of users having a hard time testing their Grid with the virtualization, it could be interesting to add a paragraph in the doc with those kind of tips. |
Hi @flaviendelangle @m4theushw v5.0.1 brings back unexpected failures, though this time you released v5 so breaking things is clearly not expected in minor releases, let alone patch ones. As usual, I'm in to refactor my tests but I'd like some guidance on what might be causing the regressions, as @m4theushw did last time. The failures apparently are related to some rows not being rendered, while they were in 5.0.0. Anything related to size or whatever again? Thx David |
It could be related to #3007. Which tests are you doing that are failing with v5.0.1? When testing with jsdom, these kind of errors are expected since it doesn't have the capability to infer the size of an element. We only test layout stuff with a real browser to avoid having to mock the dimensions. |
Yeah, and I know I should change the failing tests. I'll dig more tomorrow morning and get back to you. I'll also check #3007, thanks for the hint |
Yeah much likely #3007 |
Hi @flaviendelangle @m4theushw Actually this time tests are right, we do have one grid that does not render anymore. It's a simple one with static rows and columns. We do have other grids that render fine. One thing I noticed is that now we have this warning in the console
Side note: we do have a license for your product, we're a french company Thx, |
This warning is fired when to grid does not have a height. I see you found a workaround #2945 (comment) and I suppose that this workaround does not work anymore since you have the error again. If you are passing props to your Grid directly in your test, you could bypass the issue by publishing a let apiRef: GridApiRef
describe('', () => {
it('', () => {
const Wrapper = (props) => {
apiRef = useGridApiRef();
return <DataGridPro {...props} apiRef={apiRef} />
}
render(<Wrapper rows={rows} />)
apiRef.current.publishEvents('resize', { height: 300, width: 300 });
});
}); But depending on how your tests are structured, it can be tricky to access the If you can give me a repo with a small reproduction case I can spend some time finding a solution (and documenting it properly for everyone). |
Thx for your reply, but I was unclear sorry. It's the actual production app that suffers the regression... We do have one table that don't render in the app anymore when upgrading the lib |
I'm currently trying to repro in a repo, or a codesandbox. I'll keep you posted |
So the Using a simple hack like However, in 5.0.1 I still have the table that does not render. I'll try to reproduce this issue and get back to you |
I moved on a bit, but still can't reproduce outside my app. My findings are
I have 6 remaining failing tests that are all failures because in 5.0.1 the data grid does not render the same number of rows. All data Grids under test use Cheers, |
OK @flaviendelangle @m4theushw I finally managed to reproduce, and it was dumber than expected. As often you may say! Closing this one in favor of #3233 that I just created |
For the record, the failing tests were due to missing mocks of
|
Could you share all of the properties you had to mock to be able to unit test with jsdom? We want to add a page to help to set up a testing environment in #1151. |
Duplicates
Latest version
Current behavior 😯
We have 70 tests failing when upgrading from v5.0.0-beta.4 to v5.0.0-beta.5.
This is a loooooot higher than the usual failures that we expect (because you're still in beta). Most (probably all, but I need to dig deeper) failures are related to columns being invisible while they were in beta4, columns being absent from the DOM while there were present in beta4, or other similar assertions....
Can you advise on what might have changed in beta5 causing so many failures? I'm OK to fix these on my side, but I'd apreciate guidance on where to start :)
Thx a lot !
David
Expected behavior 🤔
No failures?
Steps to reproduce 🕹
I've no reproduction, but I can try to setup one if that's required. Basically we've lots of tests doing stuff like
expect(column).toBeVisible()
orexpect(column).toBeInTheDocument()
that are now failing.Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: