Skip to content

Integration Test

In one line

An integration test checks that two or more parts of your system work correctly when connected, catching issues that unit tests miss.

In simple words

If a unit test is like testing a car brake by itself, an integration test is like testing the brake together with the brake pedal and the hydraulic line. You're checking that the parts work correctly when connected.

Integration tests sit between unit tests and end-to-end tests. They test real connections between modules — like a service talking to a database, or two modules communicating through their interfaces.

They are slower than unit tests (because they use real dependencies) but faster than E2E tests (because they don't test through the UI). They catch problems like data format mismatches, interface incompatibilities, and incorrect wiring between components.

Example

javascript
// Integration test: repository + real database
test('user is saved and retrieved', () => {
  const db = new InMemoryDb();
  const repo = new UserRepository(db);
  repo.create({ id: 1, name: 'Alice' });
  expect(repo.findById(1).name).toBe('Alice');
});

This test uses a real database (in-memory) instead of a mock, testing the full data flow.

Common confusions

  • Confused with: Unit Test

    The difference: Integration tests use real dependencies; unit tests mock them. Integration tests are slower but catch integration bugs.

  • Confused with: E2E Test

    The difference: Integration tests check internal module interactions; E2E tests check the full user journey through the UI.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary