Testing React: A Convert’s Journey from Enzyme to Testing Library – Bonnie Schulkin

preview_player
Показать описание

🗓   TestJS Summit 2021 #TestJSSummit

Talk: Testing React: A Convert’s Journey from Enzyme to Testing Library

Abstract: Testing Library's advantages over Enzyme for testing React:
- Opinionated framework enforces best testing practices (test behavior, not integration)
- Opinions on how to find elements (by role) encourages accessibility
- jest-dom assertions lead to simple, readable tests
- ESLint plugins help encourage best practices in real time
- test output helps locate elusive elements
There will be a few code examples, but this is largely a discussion (rather than a how-to).

This event would not take place without the support of sponsors:

Platinum Sponsors

Gold Sponsors

Silver Sponsor

Production Partner
Рекомендации по теме
Комментарии
Автор

just what I was looking for, thank you!

ETFAnalyzer
Автор

Thanks for doing this. I've been wrestling with it for awhile. Testing-library clearly has the momentum and I do appreciate that the tests are easier to comprehend, and encourage accessibility testing. However, I find that this comparison (along with all the similar ones I've seen out there) do not represent enzyme tests the way I typically see them in large projects. I've found it much more common to use a lot of shallow rendered snapshot tests rather than querying for individual selectors (the exception would be when you want to simulate an event). testing-library's lack of shallow rendering can make it difficult to get to 100% coverage without writing a lot of boilerplate mocking.

bennydtown