https://github.com/shreyasdankhade/api-testing-via-jest
A comprehensive Jest-based framework for efficient and reliable API testing in Node.js applications.
https://github.com/shreyasdankhade/api-testing-via-jest
api apitesting html javascript jest jest-tests js json nodejs postman supertest
Last synced: 11 months ago
JSON representation
A comprehensive Jest-based framework for efficient and reliable API testing in Node.js applications.
- Host: GitHub
- URL: https://github.com/shreyasdankhade/api-testing-via-jest
- Owner: ShreyasDankhade
- Created: 2024-06-19T16:48:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-21T13:14:33.000Z (11 months ago)
- Last Synced: 2025-03-21T14:23:58.143Z (11 months ago)
- Topics: api, apitesting, html, javascript, jest, jest-tests, js, json, nodejs, postman, supertest
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🚀 API Testing via Jest
This repository provides a professional demonstration of API testing using Jest, a robust JavaScript testing framework. It focuses on verifying the functionality and reliability of APIs within a Node.js environment, offering structured examples and practical guidance for effective testing.
---
## 🛠️ Technologies Used
- **Node.js:** JavaScript runtime environment for backend development.
- **Jest:** A powerful JavaScript testing framework to structure and execute tests.
- **Supertest:** Library for testing HTTP endpoints efficiently.
---
## 📂 Project Structure
```
API-Testing-via-JEST/
├── MAIN.postman_collection.json # Postman collection for manual API testing
├── README.md # Project documentation
├── exam_trade.test.js # Jest tests for trade API endpoints
├── jest.config.js # Jest configuration settings
├── job_post.test.js # Jest tests for job posting API endpoints
├── test-report.html # HTML report generated by Jest
└── token.js # Token management script for authentication
```
---
## ✅ Prerequisites
Before setting up the project, ensure you have:
- [Node.js](https://nodejs.org/) (version 14.x or higher)
- [npm](https://www.npmjs.com/)
---
## ⚙️ Setup Instructions
### 1. Clone the Repository
```bash
git clone https://github.com/ShreyasDankhade/API-Testing-via-JEST.git
cd API-Testing-via-JEST
```
### 2. Install Dependencies
```bash
npm install
```
### 3. Run Tests
Execute Jest test suites using:
```bash
npm test
```
---
## 🔍 Writing and Executing Tests
### Example Jest Test
```javascript
const request = require('supertest');
const app = require('../src/app');
describe('API endpoint tests', () => {
test('GET /api should return status 200', async () => {
const response = await request(app).get('/api');
expect(response.statusCode).toBe(200);
});
});
```
---
## 🎯 Best Practices
- **Modularity**: Structure tests clearly to enhance readability and maintenance.
- **Isolation**: Use mocking to isolate tests from external dependencies.
- **Clear Descriptions**: Provide meaningful test case descriptions for easier debugging.
- **Regular Testing**: Automate test runs to detect and resolve issues promptly.
---
## 📚 Resources
- [Jest Documentation](https://jestjs.io/docs/getting-started)
- [Supertest Guide](https://github.com/visionmedia/supertest)
- [Node.js Documentation](https://nodejs.org/en/docs/)
---
## 👥 Contributors
- **Shreyas Dankhade** (Repository Owner)
- Contributions are welcome! Feel free to fork and submit pull requests.
---
## 📧 Contact
For questions or support, contact Shreyas Dankhade at shreyasdankhade75@gmail.com.