Skip to content

henriquekoaski/codeceptjs-api-tests

Repository files navigation

CodeceptJS-API-Tests

This repository contains automated end-to-end (E2E) API tests for the JSONPlaceholder service, a popular fake online REST API for testing and prototyping.

🌐 Access the documentation through this link 👉 JSONPlaceholder

image

 

🧭 Overview

In this project, I implement automated functional end-to-end (E2E) API tests using CodeceptJS with JavaScript, following BDD practices with the Gherkin language using the Cucumber tool. The goal is to ensure the quality and reliability of the JSONPlaceholder API endpoints.

 

🛠️ Technologies and Tools Used

  • JavaScript
  • CodeceptJS
  • Node.js
  • npm
  • Cucumber
  • Gherkin
  • BDD (Behavior-Driven Development)
  • Joi (Schema validation)

 

⚙️ Project Structure

This project is designed for scalability and maintainability for both current and future test scenarios.

  • features/: Contains Gherkin feature files describing the test scenarios in BDD style.
image

 

  • step_definitions/: Contains JavaScript step definitions for each feature, organized by domain (e.g., posts.steps.js, users.steps.js, and common.steps.js for shared steps).
image

 

  • data/schema/: Contains Joi schemas for validating API responses.
image

 

🧪 Automated Test Scenarios

This project covers a variety of positive and negative API scenarios, including:

  • GET all posts
  • GET post by ID
  • GET posts by userId
  • GET all users
  • CREATE a new user
  • UPDATE a user
  • DELETE a user
  • GET a user that does not exist (negative scenario, using Scenario Outline for multiple invalid IDs)

All scenarios are written in Gherkin and validated with Joi schemas for contract testing.

 

🔬 Running Tests Locally

Prerequisites

Setup

  1. Clone this repository:

    git clone https://github.com/your-username/codeceptjs-api-tests.git
    cd codeceptjs-api-tests
  2. Install dependencies:

    npm install
  3. Run the tests:

    npm test

Test results will be displayed in the terminal and logs will be available in the output/ folder.

 

📝 Example Test Output

Posts --
  √ GET all posts
  √ GET posts by id {"id":"1"}
  ...
Users --
  √ GET all users
  √ CREATE a new user
  ...
  √ GET a user that does not exist {"userId":"9999"}
  √ GET a user that does not exist {"userId":"0"}
  ...
OK  | 23 passed   // 8s

About

End-to-end (E2E) API testing project using JavaScript with CodeceptJS, BDD with Cucumber, and Joi for response validation. Functional tests for the JSONPlaceholder, a free fake and reliable API for testing and prototyping.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors