DOM Testing Library (works with React and Angular)
The tests resemble the way your software is used, and so you have more real-life confidence
Reference:
https://testing-library.com/docs/guiding-principles
The Problem
Need confidence that your components are working for your users.
Need to maintainable
Avoid implementation details (so they can handle refactors)
The solution
Light weight
Tests web pages by querying and interacting with DOM nodes.
The DOM nodes can be simulated or in the browser
Find nodes in the same way that a user would
Notes:
Not a Test runner or framework
Limited to a testing framework
Notes (avoid these)
Avoid these implementation details
- Internal state of a component
- Internal methods of a component
- Lifecycle methods of a component
- Child components
The @testing-library
family of packages helps you test UI components in a user-centric way.
Can be run in simulated mode or in an actual browser.
Works with DOM APIS such as
- Jest
- Mocha
- Mocha + JSDOM
Actual browsers