# रूट्स टेस्ट करना — एक्सप्रेस.जेएस

Source: https://www.geekswithgeeks.com/hi/expressjs/ex-testing

> supertest आपके app के ख़िलाफ़ इन-प्रोसेस असली रिक्वेस्ट चलाता है।

## HTTP परत को परखें

**supertest** आपके Express `app` को लपेटता है और टेस्ट को असली HTTP रिक्वेस्ट भेजने देता है — किसी पोर्ट को बाँधने की ज़रूरत नहीं।

## एक supertest उदाहरण

`app` को export करें बिना उसमें `listen()` बुलाए, ताकि टेस्ट इसे सीधे इंपोर्ट करें।

```javascript
import request from 'supertest';
import app from '../app.js';

test('GET /health returns ok', async () => {
  const res = await request(app).get('/health');
  expect(res.status).toBe(200);
  expect(res.body.status).toBe('ok');
});
```
