How to write tests for useTransition with v9 api?
See original GitHub issue🤓 Question
(I did search around stackoverflow and spectrum)
How to properly test useTransition
using v9 api? I’ve tried using https://github.com/react-spring/mock-raf but tests will hang with it. Also tried mocking raf to a regular:
const FPS = 16;
global.requestAnimationFrame = (callback) => {
setTimeout(callback, FPS);
};
Testing items being added seems to work as expected, but I can’t get to properly test item removal, for example:
it('should remove a notification on click', async () => {
const { queryByTestId } = renderComponent();
fireEvent.click(queryByTestId('button-selector');
expect(queryByTestId('notification-selector')).toBeTruthy();
jest.advanceTimersByTime(NOTIFICATION_TIMER);
expect(queryByTestId('notification-selector')).toBeNull();
});
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to write tests for useTransition with v9 api? #1048 - GitHub
How to properly test useTransition using v9 api? I've tried using https://github.com/react-spring/mock-raf but tests will hang with it.
Read more >useTransition - react-spring
useTransition. This hook is best suited for animating in & out datasets or items you don't particularly want to be left in the...
Read more >Unit Testing Controllers in ASP.NET Web API 2 - Microsoft Learn
A common pattern in unit tests is "arrange-act-assert": Arrange: Set up any prerequisites for the test to run. Act: Perform the test. Assert: ......
Read more >All You Need to Know About React Spring Jammed Into 1 Article
In this tutorial, we walk you through using React Spring library to provide awesome animations to your CRA (React App) and enhance your...
Read more >Animation transitions and triggers - Angular
This guide goes into depth on special transition states such as the * wildcard and void . It shows how these special states...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@aleclarson using
Globals.assign({ skipAnimation: true })
in a.test.tsx
file gives me the following error (I’m using version9.0.0-rc.3
):TypeError: Cannot read property 'assign' of undefined
Have you tried the
skipAnimation
global?We use that lib for internal tests, and it works as expected, so you’re likely misusing it.