-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Unable to see events rendered in tests #6377
Comments
Would you be able to post a runnable, stripped-down demonstration of the bug (ie. on codesandbox.io)? Would really appreciate it because the time saved reproducing will be time spent fixing. |
@acerix this is purely a new create react app with the calendar in and one test creating the issue it is not a full application by any means. I thought this would be sufficient. I've tried to slim it down as much as possible so all it is doing is rendering one event in the calendar and that works fine in the browser but does not work in tests using jsdom. Here is also a codesandbox link but I've found jsdom tests to be VERY slow (40s for a 1s test locally) and unreliable in Chrome and Firefox. Hopefully this is sufficient. |
Thanks for the details, I wasn't able to get it to run in my browser though as you mentioned it seems that system is not very reliable. Although I had a look at your test and it seems to be looking for the event element immediately after the calendar is rendered, it should work if you add a delay (eg. setTimeout) to give time for the events to render. |
@acerix I've updated the test as you suggested and added a 5 second timeout between render and creating the snapshot. This is still resulting in the same situation - no events rendered I have updated both the repo https://github.com/tgandrews/fullcalendar-test During our debugging we tried mocking time using jest and running it forward a minute and re-rendering but neither seemed to help. |
Have very similar issue. Have Fullcalendar(v5) rendered as React component. Tests configured with jest and testing-library |
Thanks for the details. I'm not very familiar with React, but it looks like you are assiging |
Yes the asFragment is a function that takes a snapshot at the time of execution. So after the timeout. When you say “react” do you mean full calendar react or the actual react library? |
Thanks for confirming, it does seem like a bug then. Does the same I mean the FullCalendar React component, we have a separate repo for issues specific to that so I will move there. |
Yes it works in the browser fine. Just not in the tests |
Same issue here. Using FullCalendar 5.5.0 with the TimeGridWeek view. Everything works fine in the browser, but in my test suite, only allDay events are rendered, not regular events. The test suite passed on v4.4.0. It seems like the eventContent callback is not called for regular events. |
I observed that the issue happens to me only when I use the |
Having the same issue while using resourceTimeGridPlugin. Tried stripping it down to a calendar with a single event passed via |
First, nice work you are doing here. I like this concept of having plugins based on needs. But I have the same issue when trying to test with jest with @testing-library/react. Everything works when running the project in the browser either storybook, but I try to log the rendered component during the tests just the resources are rendered. For the events the table row for each is missing the custom content
A colleague found out with the @fullcalendar/daygrid plugin the events are rendered and not with the @fullcalendar/resource-timeline plugin. I started to look how are the tests in this project and besides it is using jasmine and karma it renders the elements with @fullcalendar/resource-timeline plugin fine. Also if the maintainers could help to understand or help find a solution to make it work with others test libraries. By the way I feel the test coverage in this project should be improved and maybe cover all plugins with different scenarios. |
I will take a look at this very soon. This likely started happening because of my event-positioning refactor. In a Jest environment there isn't a real DOM with real coordinates. In previous version of FullCalendar, events must have rendered even without available coordinates, whereas now it is likely waiting for non-zero coordinates as a precondition for rendering. I'll take a look. |
I believe I've found where rendering is short-circuiting when no available coordinates:
The next step is to modify the code so events are rendered unconditionally, even without coordinates, which may required a tiny bit of refactoring. |
Thanks for the quick answer Adam. Based on that new version my dependencies now are
But the issue is still there. I guess the next step is that refactoring you mentioned. Looking forward to it. |
this has been implemented and queued for release. |
this fix has been released in v5.8.0 |
How would you refactor the code so that the events are unconditionally rendered? Asking this because I have trouble testing events right now in daygrid |
Reduced Test Case
yarn
yarn start
see the events renderedyarn test
see the tests pass but the snapshot include no events insrc/__snapshots__/App.test.js.snap
Bug Description
Describe how to recreate the bug.
Follow the steps above to be able to recreate. This works with v4 providing that is used instead.
What do you expect to happen?
I expect events to be rendered in test environments
What happens instead?
No events are rendered in tests even after waiting for a long time 20seconds in the linked example
The text was updated successfully, but these errors were encountered: