Skip to content

benjaminpinto/ServerRestTest

Repository files navigation

ServeRest API and E2E test suite

Badge ServeRest Cypress Tests

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.

Pre-requirements

It is required to have Node.js and npm installed to run this project.

I used versions v16.15.0 and 8.5.5 of Node.js and npm, respectively. I recommend you to use the same or later versions.

Installation

Run npm install (or npm i for the short version) to install the dev dependencies.

Tests

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 as cypress.env.json, and update variable's values. In this project, it's mandatory that exists a cypress.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 of cypress.env.json file. This post shows how to do it.

About the tests

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.

Finally, just some tips to understand the code

  • 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 and gui_tests.
  • Custom commands are defined at api_commands and gui_commands

This project was created by Benjamin Pinto.

About

E2E and API tests at ServeRest

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published