Skip to content

Repository files navigation

Real API Automation Framework

A REST API automation framework built with JavaScript and Node.js for testing RESTful APIs using modern automation practices.

It demonstrates API functional testing, schema validation, data-driven testing, mock testing, basic performance testing, Docker, Docker Compose, and GitHub Actions.


Project Overview

This project tests the public JSONPlaceholder REST API and demonstrates how an API automation framework can be organized with a clean structure, reusable components, and easy maintenance.

The framework includes reusable utilities, separated test data, schema validation, mocked responses, Docker support, and automated test execution through GitHub Actions.


Technologies

  • JavaScript
  • Node.js
  • Supertest
  • Mocha
  • Chai
  • AJV
  • Nock
  • Docker
  • Docker Compose
  • GitHub Actions
  • Grafana k6

Project Structure

real-api-automation-project
│
├── .github/
│   └── workflows/
│       └── ci.yml
│
├── config/
│   └── config.js
│
├── data/
│   └── users.data.json
│
├── mocks/
│   └── users.mock.test.js
│
├── performance/
│   └── load-test.js
│
├── schemas/
│   └── user.schema.json
│
├── tests/
│   ├── data-driven/
│   ├── negative/
│   ├── posts/
│   └── users/
│
├── utils/
│   ├── helpers.js
│   ├── logger.js
│   ├── request.js
│   ├── retry.js
│   └── validator.js
│
├── Dockerfile
├── docker-compose.yml
├── package.json
└── README.md

Test Coverage

Users API

  • Get all users
  • Get user by ID
  • Create a new user
  • Update a user
  • Delete a user

Posts API

  • Get all posts
  • Get post by ID
  • Create a new post
  • Update a post
  • Partially update a post
  • Delete a post

Negative Testing

  • Invalid endpoint
  • Resource not found
  • Mocked server error using Nock

Schema Validation

API responses are validated against JSON Schemas using AJV to ensure response consistency.

Data-Driven Testing

Test data is separated from the test logic using external JSON files, making test cases easier to maintain and extend.

Mock Testing

API responses are mocked using Nock to simulate different server behaviors without calling the real API.

Performance Testing

Basic API load testing is implemented using Grafana k6.

Current configuration:

  • 5 Virtual Users (VUs)
  • 10 seconds duration
  • HTTP status validation

Run the performance test:

k6 run performance/load-test.js

Test Results

Current automated test suite:

15 Functional Tests Passing
3 Mock Tests Passing

The project has been successfully tested:

  • Locally
  • Inside Docker
  • Using Docker Compose
  • Through GitHub Actions CI

Running the Project

Clone the repository

git clone https://github.com/coderaliennadafy/Real-API-Automation-Project.git

Move into the project directory

cd Real-API-Automation-Project

Install dependencies

npm install

Run all functional tests

npm test

Run mock tests

npm run test:mocks

Docker

Build the Docker image

docker build -t api-automation .

Run the test suite inside a container

docker run --rm api-automation

Run using Docker Compose

docker compose up

Continuous Integration

GitHub Actions automatically runs the test suite on every push to the master branch.

The workflow performs the following steps:

  • Checkout repository
  • Setup Node.js
  • Install project dependencies
  • Run the complete test suite

Current Features

  • REST API Functional Testing
  • CRUD Operations
  • Positive & Negative Testing
  • Data-Driven Testing
  • JSON Schema Validation (AJV)
  • Mock API Testing (Nock)
  • Basic Performance Testing (Grafana k6)
  • Docker Support
  • Docker Compose
  • GitHub Actions CI

Future Improvements

  • Playwright API Testing
  • HTML Test Reports
  • Allure Reporting
  • Advanced Performance Testing
  • API Authentication Testing

Author

Ali Ennadafy

Software QA Tester focused on API testing, automation, and software quality.

GitHub
https://github.com/coderaliennadafy

Portfolio
https://ali-ennadafy-portfolio.netlify.app/

About

REST API automation framework built with JavaScript, Supertest, Docker, GitHub Actions and k6.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages