# Routes को Test करना — Fastify

Source: https://www.geekswithgeeks.com/hi/fastify/ff-testing

> अपने Fastify routes के लिए तेज़ tests लिखें।

## In-process testing

Fastify directly requests inject कर सकता है बिना real server शुरू किए—unit और integration tests के लिए आदर्श।

## Inject के साथ testing

Requests भेजने और responses को verify करने के लिए `fastify.inject()` उपयोग करें।

```javascript
import test from 'node:test';
import assert from 'node:assert';
import build from './app.js';

test('GET /health returns 200', async () => {
  const fastify = await build();
  
  const response = await fastify.inject({
    method: 'GET',
    url: '/health',
  });
  
  assert.equal(response.statusCode, 200);
  assert.deepEqual(JSON.parse(response.body), { status: 'ok' });
  
  await fastify.close();
});
```
