This project provides an overview and demonstration of API Testing using Cypress, covering a variety of essential topics related to HTTP methods, post request creation, request authentication, payload handling and request chaining.
- HTTP Methods
- Creating Post Request Body
- Handling Query Parameters, Headers, Cookies & Bearer Tokens
- Parsing JSON Response Body
- JSON Schema Validation
- XML Payload Handling and Parsing XML Response
- API Authentications
- OAuth 2.0 Authentication - GitHub App
- Request Chaining
This section will demonstrate the different HTTP methods like GET, POST, PUT, PATCH, DELETE, etc. It provides examples of how to test APIs using these methods in Cypress.
This part provides an understanding of the different ways to create a post request body in Cypress. It includes using inline JSON objects, using JSON body from a file, and dynamically creating JSON body.
Here, we explain how to handle various elements of API requests such as query parameters, headers, cookies, and bearer token authentication. It includes how to set and use these in your Cypress API tests.
This section discusses parsing the JSON response body from an API call. We provide a step-by-step guide on how to parse and extract data from JSON responses for further validations or chaining requests.
This part is about validating the structure of your JSON response using JSON Schema. It describes how to define and use a JSON schema for robust response validation in your API tests.
In this section, we tackle how to handle XML payloads and parse XML responses from APIs. It includes the essentials of dealing with XML in your API tests.
This part delves into API Authentication methods, namely Basic, Digest, Bearer Token, and API Key. It covers how to authenticate APIs with these methods in your Cypress tests.
Here, we discuss how to authenticate APIs using OAuth 2.0. Specifically, we illustrate an example with the GitHub App. This part provides an understanding of the OAuth 2.0 flow and its implementation in Cypress.
The final section covers request chaining, which involves using the response from one API request in another. We demonstrate how to implement request chaining in Cypress, providing valuable insights into its usage in real-world API testing scenarios.