Skip to content

Commit

Permalink
Updated README for Lesson 7: Topic 5 assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
aasimsyed committed Apr 20, 2024
1 parent 0e7c0a8 commit a476abb
Showing 1 changed file with 4 additions and 104 deletions.
108 changes: 4 additions & 104 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,109 +1,9 @@
# API Test Suite Documentation for Restful Booker
# Integrating GitHub Actions into an Existing GitHub Repo

## Overview

This repository contains a comprehensive API test suite for the Restful Booker platform, designed to ensure the reliability and correctness of its API endpoints through automated testing using Cypress.
The objective of this project is to integrate GitHub Actions into your existing GitHub project.

## Prerequisites
## GitHub Actions Run

- Node.js (version 12 or higher)
- npm (comes with Node.js)
- Cypress
- AJV and AJV-formats for schema validation (for validating API responses against JSON schemas)

Ensure all dependencies are installed by running:

```bash
npm install cypress ajv ajv-formats --save-dev
```

## Installation

Clone the repository and install dependencies to set up the project on your local machine:

```bash
git clone https://github.com/aasimsyed/coding-temple-cypress-playground
cd coding-temple-cypress-playground
npm install
```

## Running Tests

To open the Cypress Test Runner for interactive testing:

```bash
npx cypress open
```

To run tests headlessly suitable for CI environments:

```bash
npx cypress run
```

## Configuration

The cypress.config.js file is configured to handle environment variables and setup preferences:

```javascript
const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
env: {
restfulBookerUrl: 'https://restful-booker.herokuapp.com'
},
chromeWebSecurity: false,
supportFile: 'cypress/support/commands.js',
specPattern: [
'cypress/integration/e2e/**/*.spec.js',
'cypress/integration/api/**/*.spec.js'
],
setupNodeEvents(on, config) {
// Event listeners can be defined here
}
}
});
```

## Custom Commands

Custom Cypress commands enhance test readability and reusability:

- *apiRequest*: Abstracts making API requests with dynamic inputs.
- *createBooking*: Wraps the apiRequest to create bookings.
- *deleteBooking*: Utilizes apiRequest to delete bookings based on ID.

These are defined in *cypress/support/commands.js*.

## Schema Validation

API response validation is performed using AJV combined with schemas defined in cypress/schemas. This ensures responses adhere to expected formats, crucial for API integrity.

## Using Fixtures

Fixtures are used to manage and maintain test data separate from test logic, located under cypress/fixtures. This allows easy management of test data without altering the test scripts.

## Best Practices Employed

- *Modular Test Structure*: Each API endpoint has dedicated test files under cypress/integration, making tests easier to manage and debug.
- *Environment Abstraction*: Configuration details are abstracted into cypress.config.js, allowing easy changes without code adjustments.
- *Schema Validation*: Ensures the API's output remains consistent, catching potential breaking changes.
- *Custom Commands*: Reduces code duplication and increases the maintainability of tests.
- *Efficient Use of Fixtures*: Separates test data from test logic, improving test clarity and ease of updates.

## Potential Future Improvements

- *Parallel Testing*: Implement Cypress's parallel execution capabilities to reduce test run times.
- *Increased Coverage*: Expand tests to cover more scenarios and edge cases.
- *Continuous Integration*: Integrate with CI/CD pipelines for automated running of tests upon code commits or at scheduled intervals.
- *Security Testing*: Integrate security-focused tests to identify and mitigate potential vulnerabilities.

## Project URL

- https://github.com/aasimsyed/coding-temple-cypress-playground
- PR for these change: https://github.com/aasimsyed/coding-temple-cypress-playground/pull/4

## Conclusion

The implemented test suite serves as a robust foundation for ongoing development, ensuring high standards of quality and reliability for the Restful Booker API. By adhering to best practices, this suite facilitates efficient testing and future expansion.
- [GitHub Actions Run](https://github.com/aasimsyed/coding-temple-cypress-playground/actions/runs/8761555437)

0 comments on commit a476abb

Please sign in to comment.