Introduction
This blog will help you understand the Angular Testing Library with an example.
Angular Testing Library is essentially a testing library that builds on top of the DOM Testing Library by adding APIs for working with Angular components.
Angular Testing Library
The Angular Testing Library is a light and efficient solution for testing an Angular component. Angular Testing Library provides utility functions on top of the DOM(Document Object Model) Testing Library in a way that enables better testing practices, and its primary guiding principle is
The more a test resembles the way software is used, the more effortless it is to understand and provides more confidence.
Hence, instead of dealing with instances of a rendered Angular component, the tests will work with the actual DOM nodes.
Essentially, a developer has the ability to query the DOM similar to how a user does with the help of Utilities in the Angular Testing Library. Meaning being able to find links and buttons from a text.
Lastly, the Angular Testing Library promotes a more accessible and friendly application by allowing a developer to test a component the way an end-user would.
The Angular Testing Library:
- Is testing framework that runs on every test framework
- Re-exports the query and fireEvent utility functions from the DOM Testing Library.
- Envelopes fireEvent functions of a component in order to call detectChanges() after event occurs automatically.