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
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.
- JavaScript
- CodeceptJS
- Node.js
- npm
- Cucumber
- Gherkin
- BDD (Behavior-Driven Development)
- Joi (Schema validation)
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.
step_definitions/: Contains JavaScript step definitions for each feature, organized by domain (e.g.,posts.steps.js,users.steps.js, andcommon.steps.jsfor shared steps).
data/schema/: Contains Joi schemas for validating API responses.
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.
-
Clone this repository:
git clone https://github.com/your-username/codeceptjs-api-tests.git cd codeceptjs-api-tests -
Install dependencies:
npm install
-
Run the tests:
npm test
Test results will be displayed in the terminal and logs will be available in the output/ folder.
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