This project automates different API responses from https://reqres.in/ using the Cypress framework, generating reports and running into github actions as CI.
Some of the API request that were automated are listed below:
GET /api/users
Request type | Endpoints | Expected Response Code |
---|---|---|
GET |
/api/users?page=2 |
200 |
GET /api/unknown
Request type | Endpoints | Expected Response Code |
---|---|---|
GET |
/api/unknown |
200 |
POST /api/users
Request type | Endpoints | Request Body | Expected Response Code |
---|---|---|---|
POST |
/api/users |
name : morpheus, job : leader |
201 |
PUT /api/users/2
Request type | Endpoints | Request Body | Expected Response Code |
---|---|---|---|
PUT |
/api/users/2 |
name: morpheus, job: zion resident |
200 |
PATCH /api/users/2
Request type | Endpoints | Request Body | Expected Response Code |
---|---|---|---|
PATCH |
/api/users/2 |
name: morpheus, job: zion resident |
200 |
DELETE /api/users/2
Request type | Endpoints | Expected Response Code |
---|---|---|
DELETE |
api/register |
204 |
POST /api/register
Request type | Endpoints | Request Body | Expected Response Code |
---|---|---|---|
POST |
/api/register |
email=eve.holt@reqres.in, password=pistol |
200 |
POST /api/register
Request type | Endpoints | Request Body | Expected Response Code |
---|---|---|---|
POST |
/api/register |
"email":"sydney@fife" |
400 |
POST /api/login
Request type | Endpoints | Request Body | Expected Response Code |
---|---|---|---|
POST |
/api/login |
email: eve.holt@reqres.in, password:cityslicka |
200 |
POST /api/login
Request type | Endpoints | Request Body | Expected Response Code |
---|---|---|---|
POST |
/api/login |
email: peter@klaven |
400 |
- Nodejs. must be installed in order to run the project.
- Clone the repository from Github.
git clone https://github.com/RaffyRod/Cypress-API-Testing.git
- Install all packages and dependencies for the project.
npm install
Go to the project directory
cd Cypress-API-Testing
Install dependencies
npm install
npx cypress open
-
Select E2E testing in order to get access.
-
Select a browser from the list (chrome is always a good option).
-
Start testing any API file by just clicking on it.
Go to the project directory
cd Cypress-API-Testing
From the terminal type in
npm run test-windows
In order to run the project on Windows OS.
or
npm run test
In order to run the project on Linux and Mac OS.
- After running a HTML report will be generated and saved at the
cypress/reports
folder.
- For API negative test cases was used
failOnStatusCode: false
, so it can continue and do the assertions. - It was implemented the ESlint linter to ensured the code best practices and performance.
- It was commented only specific parts of the code, if someone reads teh entire code easily will understand it.
- In order to locally run the Linter (ESlint) just type in the terminal
npm run lint
or to run and fixnpm run lint-fix