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.
- 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.
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
Before setting up the project, ensure you have:
git clone https://github.com/ShreyasDankhade/API-Testing-via-JEST.git
cd API-Testing-via-JEST
npm install
Execute Jest test suites using:
npm test
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);
});
});
- 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.
- Shreyas Dankhade (Repository Owner)
- Contributions are welcome! Feel free to fork and submit pull requests.
For questions or support, contact Shreyas Dankhade at shreyasdankhade75@gmail.com.