Lesson 24 / 34

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.

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.