Timeline for Unit test for a React click-counting component
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 6, 2022 at 22:03 | comment | added | user8758206 | that's interesting to know. A course I also undertook also suggested just using userEvent over fireEvent, although it seems that they're both similar and that both would probably work. You can only get so far with unit tests and I am yet to explore e2e tests, and as you say, they will probably provide a better simulation for those cases | |
Jul 6, 2022 at 21:41 | comment | added | ggorlen |
Good question. Going back to Kent's article I linked throughout, there's a section: Not using @testing-library/user-event which mimics the user's actions better. TBH, I've just used fireEvent which has been sufficient for my unit testing needs. I've relied on E2E tests with Puppeteer/Cypress to provide that "real user" simulation with trusted events, but Kent's the expert, and it seems good to apply that philosophy to unit tests too.
|
|
Jul 6, 2022 at 21:37 | comment | added | user8758206 | great advice, thank you very much for your help! quick question: do you know what is best to use for button clicks? e.g. dispatchEvent vs fireEvent (as you pointed out) vs userEvent? It seems like there are many ways to skin a cat but the best way is unclear | |
Jul 6, 2022 at 21:35 | vote | accept | user8758206 | ||
Jul 5, 2022 at 21:43 | history | edited | ggorlen | CC BY-SA 4.0 |
deleted 17 characters in body
|
Jul 5, 2022 at 21:38 | history | edited | ggorlen | CC BY-SA 4.0 |
adjust last header to be less confusing
|
Jul 5, 2022 at 21:32 | history | answered | ggorlen | CC BY-SA 4.0 |