Sample project to show the use of Cypress to test ServeRest API and Front End.
To get more details about booth, front and backend, visit ServeRest's Github page.
In a real scenario, considering that front and backend are different projects ate ServeRest, we should have also two separated test projects. However, this is a sample project in wich I'm just doing a hand's on with Cypress, then API and E2E tests are being made here.
It is required to have Node.js and npm installed to run this project.
I used versions
v16.15.0
and8.5.5
of Node.js and npm, respectively. I recommend you to use the same or later versions.
Run npm install
(or npm i
for the short version) to install the dev dependencies.
Run npm test
(or npm t
for the short version) to run the test in headless mode.
Or, run npm run cy:open
to open Cypress in interactive mode.
Note: Before running the tests, make a copy of the
cypress.env.example.json
file ascypress.env.json
, and update variable's values. In this project, it's mandatory that exists acypress.env.json
file, so don't forget it.In order to simulate a real use case that use sensible data,
cypress.env.json
file is included on.gitignore
and it's safe that confidential info won't be versioned.
Important: This project uses Github actions to CI. Considering that
cypress.env.json
isn't sent to repository for security reason, if you want it running at your own Github account (fork), you must add an secret entry at project's configuration page with the content ofcypress.env.json
file. This post shows how to do it.
The purpose of this project is to be an use case of how we can perform E2E and API tests upon a real application using Cypress.
- We are using the online endpoint of ServeRest. According to it's documentation page, all data stored are cleaned daily, at 3am.
- Due to make tests independent and fast, even in frontend, repeatable steps are made by using API calls, instead of repeatedly do it from GUI (ex: login). We will mock all the frontend soon.
- Spec files are organized in two main folders:
api_tests
andgui_tests
. - Custom commands are defined at
api_commands
andgui_commands
This project was created by Benjamin Pinto.