-
Notifications
You must be signed in to change notification settings - Fork 337
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 test with React Testing Library #107
Comments
https://github.com/SimeonRolev/test-react-hot-toast/tree/jest-fake-timers |
The problem is in the Toaster component: react-hot-toast/src/components/toaster.tsx Lines 84 to 88 in c5e5935
In jsdom I'm not sure what to do about this, though. |
The solution is basically to memoize the ref created by Would a PR be welcome? I can send one next week. |
Wow, thanks @silvenon for your investigations! A PR would be very welcome. |
Will silvenon's PR be merged for this project? Would love to use |
@silvenon's PR will be merged? |
I forked the code in the document and added a test. |
@pipboy3000 yep, the test("show Toast", async () => {
render(<App />);
const addButton = await screen.findByText("Add Toast");
await userEvent.click(addButton); // notice the await here!
await screen.findByText(/Hello World/)
}); The reason why we know this fixes the test is that without the One more thing regarding the test, I'm not entirely sure why the lack of Btw, in case the reason for the infinite loop is not clear, it's same as in the |
@timolins this can be closed. |
Hi, guys,
I work on a project where this library fits pretty well, but I want to test my end product. However, I wasn't able to do so, for some reason. I've used React Testing Library for tons of tests, so I guess it's something in the way these toasts work that I don't understand. Does the disappearance of the toasts depend on something that 'jsdom' can't handle?
Made a minimal reproduction repository with some simple explanations here: https://github.com/SimeonRolev/test-react-hot-toast. It has a single test for the "Close button".
Testing example:
https://testing-library.com/docs/guide-disappearance
Thanks in advance!
The text was updated successfully, but these errors were encountered: