Preact Testing Library on GitHub
npm install --save-dev @testing-library/preact
yarn add --dev @testing-library/preact
This library is built on top of
DOM Testing Librarywhich is where most of the logic behind the queries is.
You want to write tests for your Preact components so that they avoid including implementation details, and are maintainable in the long run.
The Preact Testing Library is a very lightweight solution for testing Preact
components. It provides light utility functions on top of
in a way that encourages better testing practices. Its primary guiding principle
The more your tests resemble the way your software is used, the more confidence they can give you.
See the Dom introduction and React introduction for a more in-depth explanation.
What this library is not:
- A test runner or framework.
- Specific to a testing framework.
We recommend Jest as our preference. You can checkout Using Without Jest if you're looking to use another framework.