Skip to content

ShreyasDankhade/API-Testing-via-JEST

Repository files navigation

🚀 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:


⚙️ Setup Instructions

1. Clone the Repository

git clone https://github.com/ShreyasDankhade/API-Testing-via-JEST.git
cd API-Testing-via-JEST

2. Install Dependencies

npm install

3. Run Tests

Execute Jest test suites using:

npm test

🔍 Writing and Executing Tests

Example Jest 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);
  });
});

🎯 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


👥 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.

About

A comprehensive Jest-based framework for efficient and reliable API testing in Node.js applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published