A specialized test automation framework demonstrating Direct API Testing and Frontend Isolation (Network Mocking) using Cypress and TypeScript. Built against the Restful-Booker Platform.
While UI testing is essential, it can be slow and flaky. This project showcases how to achieve faster, more reliable testing by:
- API Testing: Interacting directly with the backend to validate status codes, JSON responses, and Auth Tokens.
- Network Mocking (
cy.intercept): Intercepting real API calls from the UI and injecting mock data (stubbing) to test edge cases without relying on the backend database.
- Tool: Cypress
- Language: TypeScript
- Target Application: Restful-Booker Platform (React-based Hotel Booking App)
- Key Cypress Commands:
cy.request(),cy.intercept(),cy.wait()
Bypassed the UI to test endpoints directly. Successfully implemented a POST request to login as an admin, retrieve the JWT Auth Token, and validate the response structure.
Used cy.intercept() to catch the GET request fetching hotel rooms and injected a fake $5000 Cypress Presidential Suite. This proves the ability to test UI edge-cases by controlling the network layer.
(Note: Implemented uncaught:exception handling to bypass React hydration errors caused by injected data).
cypress/e2e/api/- Contains direct API tests (cy.request)cypress/e2e/mocking/- Contains network intercept tests (cy.intercept)cypress.config.ts- Base URLs and environment configurations
- Clone the repository.
- Install dependencies:
npm install - Run tests via Cypress UI:
npx cypress open - Execute in terminal:
npx cypress run

