Skip to content

"A repository containing API testing examples using the Cypress framework, providing a quick and easy approach to testing APIs with a focus on simplicity and ease of use."

License

Notifications You must be signed in to change notification settings

ashikkumar23/api-testing-cypress

Repository files navigation

Cypress REST API Test Framework

Actions Status Actions Status Actions Status

API Testing Framework using Cypress with GitHub Actions workflow for generating and publishing test report

🚀 Description:

Automated CRUD (i.e., POST, GET, PUT, DELETE) operations using Cypress

🚀 Prerequisites:

🚀 Installation Steps:

  • Fork and Clone the repository api-testing-cypress
  • Move to the api-testing-cypress directory:
cd api-testing-cypress
  • Set up a new npm package:
npm init
  • Install cypress:
npm install cypress
  • Add the following lines to the package.json file, "scripts" section:
  "scripts": {
    "cypress:open": "./node_modules/.bin/cypress open",
    "cypress:run": "./node_modules/.bin/cypress run --spec **/*.cy.js"
  }

🚀 Test Execution:

  • To run the tests on your terminal:
npm run cypress:run
npm run cypress:open
  • On Cypress Test Runner:
    • Select E2E Testing
    • Choose a browser: Chrome or Electron
    • Click on Start E2E Testing in {browser}
    • Once the test runner has loaded, click on the spec file i.e., test_crud.cy.js to run the test

🚀 Reporting:

npm install --save-dev mocha cypress-multi-reporters mochawesome
npm install --save-dev mochawesome-merge
npm install --save-dev mochawesome-report-generator
  • Add the following lines to the package.json file, "scripts" section:
  "scripts": {
    "report:merge": "mochawesome-merge cypress/reports/json/*.json > index.json",
    "report:generate": "marge index.json --reportDir public --assetsDir public/assets --reportPageTitle index.html"
  }

🚀 Notes:

  • .github/workflows/package_update.yml workflow would ensure the dependencies are up-to-date
  • Tests are always run on the latest dependencies ✅