# E2E Testing — NestJS: Scalable Node.js APIs बनाना

Source: https://www.skillbyai.com/hi/nestjs/nestjs-e2e-testing

> अलग test database, fixtures, cleanup और CI-अनुकूल configuration के साथ end-to-end tests चलाएँ।

## E2E setup और fixtures

Test database और fixtures को setup करें; हर test के बाद उन्हें tear down करें।

```typescript
beforeAll(async () => {
  // spin up test database
  // seed with test data
});

afterEach(async () => {
  // clean up created records
});

afterAll(async () => {
  // tear down test database
  await app.close();
});
```

## Test vs prod config को अलग करें

अलग database के साथ `.env.test` का उपयोग करें; आपका CI इसे पढ़ सकता है और हर test run के लिए clean DB spin up कर सकता है।
