First Cypress Test
A good unit or integration test needs to start from a well-known situation.
For a smooth testing process, we can expose certain
REST API endpoints that will put the database in a well-known state. This could be empty, with a few test users, or with many users to test pagination, etc.
Let’s start by adding
@RestControllerto call the endpoints from the Cypress tests.
All endpoints will be served at
These endpoints should only be started when running as a test. This mustn’t be exposed when running on production as it wipes the complete database.
UserServicein order to create the default users.
Add an endpoint
/reset-dbso the Cypress test can do a
POSTcall on it.
Create a user with the role