Author: Thomas Laforge
Testing is a crucial step in building scalable, maintainable, and trustworthy applications. Testing should never be avoided, even in the face of short deadlines or strong pressure from the product team. Nowadays, there are numerous awesome tools available that make it easy to test your code and provide a great developer experience.
In this series of testing exercises, we will learn and master Testing Library and Cypress Component Testing that simplifies DOM manipulation for testing any Angular component.
We have a functional application that lists available books for borrowing inside a library. If the book you searched is available, you will be directed to the corresponding book(s), otherwise, you will end up on an error page.
The goal is to test this behavior with Testing library and Cypress
The file named app.component.spec.ts
will let test your application using Testing Library. To run the test suits, you need to run npx nx test testing-router-outlet
. You can also install Jest Runner to execute your test by clicking on the Run
button above each describe
or it
blocks.
For testing cypress, you will execute your test inside the app.component.cy.ts
and run npx nx component-test testing-router-outlet
to execute your test suits. You can add the --watch
flag to execute your test in watch mode.
I created some it
blocks but feel free to add more test if you like to.
- Fork the project
- clone it
- npm ci
npx nx serve testing-router-outlet
to play with the applicationnpx nx test testing-router-outlet
to test your application with Testing Librarynpx nx component-test testing-router-outlet --watch
to test your application with Cypress- ...work on it
- Commit your work
- Submit a PR with a title beginning with Answer:17 that I will review and other dev can review.