https://github.com/henriquekoaski/codeceptjs-api-tests
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.
https://github.com/henriquekoaski/codeceptjs-api-tests
api-rest bdd codeceptjs cucumber functional-testing gherkin-language javascript joi-validation
Last synced: 4 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/henriquekoaski/codeceptjs-api-tests
- Owner: henriquekoaski
- Created: 2025-07-23T01:40:38.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-07-23T03:41:22.000Z (5 months ago)
- Last Synced: 2025-07-23T05:27:18.920Z (5 months ago)
- Topics: api-rest, bdd, codeceptjs, cucumber, functional-testing, gherkin-language, javascript, joi-validation
- Language: JavaScript
- Homepage: https://jsonplaceholder.typicode.com
- Size: 115 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://jsonplaceholder.typicode.com/)

ย
## ๐งญ 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.

ย
- **`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).

ย
- **`data/schema/`**: Contains Joi schemas for validating API responses.

ย
## ๐งช 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
- [Node.js](https://nodejs.org/en/) (v14+ recommended)
- [npm](https://www.npmjs.com/)
- [Git](https://git-scm.com/)
### Setup
1. **Clone this repository:**
```bash
git clone https://github.com/your-username/codeceptjs-api-tests.git
cd codeceptjs-api-tests
```
2. **Install dependencies:**
```bash
npm install
```
3. **Run the tests:**
```bash
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
```