https://github.com/zafir100100/api-testing-on-jsonplaceholder-with-jest
This project provides unit tests for API endpoints using Jest, Axios, and Faker. It includes test suites for both PostController and UserController, which interact with a public API (https://jsonplaceholder.typicode.com).
https://github.com/zafir100100/api-testing-on-jsonplaceholder-with-jest
api-testing ci-cd cjs github-actions jest jest-html-reporter nodejs test-suite unit-testing
Last synced: about 2 months ago
JSON representation
This project provides unit tests for API endpoints using Jest, Axios, and Faker. It includes test suites for both PostController and UserController, which interact with a public API (https://jsonplaceholder.typicode.com).
- Host: GitHub
- URL: https://github.com/zafir100100/api-testing-on-jsonplaceholder-with-jest
- Owner: zafir100100
- Created: 2025-03-27T05:58:30.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-10T09:39:16.000Z (about 1 year ago)
- Last Synced: 2025-06-05T04:12:50.791Z (about 1 year ago)
- Topics: api-testing, ci-cd, cjs, github-actions, jest, jest-html-reporter, nodejs, test-suite, unit-testing
- Language: JavaScript
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Api Testing on JsonPlaceHolder with Jest
This project provides unit tests for API endpoints using **Jest**, **Axios**, and **Faker**. It includes test suites for both **PostController** and **UserController**, which interact with a public API (https://jsonplaceholder.typicode.com).
## Video
https://github.com/user-attachments/assets/28fcd228-3b74-4824-85a3-bd892fabf8d4
## How to run this project
```sh
# Clone this project
# Install dependencies
npm install
# Run tests:
npm run test
```
## Test Scenarios
### PostController
1. **Get All Posts** - Verify that all posts are fetched correctly.
2. **Get Post By ID** - Verify that a specific post is retrieved successfully.
3. **Create a Post** - Ensure that a new post is created successfully.
4. **Update a Post** - Verify that an existing post is updated correctly.
5. **Delete a Post** - Ensure that a post is deleted successfully.
### UserController
1. **Get All Users** - Verify that all users are fetched correctly.
2. **Get User By ID** - Verify that a specific user is retrieved successfully.
3. **Create a User** - Ensure that a new user is created successfully.
4. **Update a User** - Verify that an existing user is updated correctly.
5. **Delete a User** - Ensure that a user is deleted successfully.
## Dependencies
```json
"devDependencies": {
"@faker-js/faker": "^9.6.0",
"axios": "^1.8.4",
"jest": "^29.7.0",
"jest-html-reporter": "^4.1.0"
}
```
## Screenshot (Jest HTML Report)

## Screenshot (Jenkins build report)






