# E2E Testing — NestJS: Building Scalable Node.js APIs

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

> Run end-to-end tests against a separate test database with fixtures, cleanup and CI-friendly configuration.

## E2E setup & fixtures

Set up a test database and fixtures; tear them down after each test.

```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();
});
```

## Separate test vs prod config

Use `.env.test` with a separate database; your CI can read it and spin up a clean DB for each test run.
