Software Testing Guide: Unit, Integration and E2E Tests

Good tests let you change code without fear; bad tests slow you down. This guide follows the testing series from why we test and the shapes of a test suite to unit, UI, API and end-to-end tests, then TDD and mutation testing.

Every example was run, including the flaky tests that were reproduced and fixed.

Who it is for: Developers who want a clear testing strategy, and candidates preparing for testing questions.

10 lessons · Published by Jainik · Last updated

1. The foundations

  1. 1. Testing From Zero · 12 min
    Why We Test, and the Shapes of a Test Suite

    What tests prove and do not prove, the pyramid, trophy and honeycomb as models, what to test, a first node:test run, and bad tests.

  2. 2. Testing From Zero · 13 min
    Unit Tests and Test Doubles

    Arrange-act-assert, stubs, mocks, spies and fakes, fake timers, async errors, test isolation, and why mocking your own internals hurts.

2. UI, API and end-to-end tests

  1. 3. Testing From Zero · 13 min
    Testing UI Components with Testing Library

    Queries by role, user-event, async UI, mocking the network with MSW, forms and error states.

  2. 4. Testing From Zero · 15 min
    Integration and API Tests

    Testing an Express API in-process, test database strategies, contracts, webhooks and queues.

  3. 5. Testing From Zero · 17 min
    End-to-End Tests with Playwright, and Fixing Flaky Tests

    Playwright locators, auto-waiting, traces and isolation, with four flaky tests reproduced and fixed.

3. TDD and a team strategy

  1. 6. Testing From Zero · 19 min
    TDD, Property-Based Testing, Mutation Testing and a Team Strategy

    A TDD kata, fast-check shrinking, Stryker mutation testing, coverage, and a one-page team test strategy.

  2. 7. Team Lead Mindset · 16 min
    Technical Debt, Quality and the Rewrite Trap

    Debt as a loan with interest, refactor or rewrite, a test plan, what to monitor, and lessons from five famous public outages.

4. Tools and interview questions

  1. 8. Full-Stack Questions · 28 min
    Testing Tools: Jest, Vitest, Testing Library, Playwright

    Mocks and fake timers, MSW, user-event, testing hooks and Server Components, Playwright locators and flaky tests, database tests with Prisma.

  2. 9. Senior Frontend Depth · 15 min
    Frontend Testing Strategy: Unit, Integration, E2E and What to Skip

    Test what users see, not how the code is built. Mock the network, not your modules. Keep end-to-end tests for the key flows only.

  3. 10. Backend in Depth · 15 min
    Testing an API: Unit, Integration and Contract

    Where to spend your testing effort in a backend, testing against a real database, and contract tests between the frontend and the API.

More reading orders are on the guides page, and every series is listed on the home page.