Skip to article content
FrontendXLesson 07 / 16

End-to-End Test Gates

Take one task-board application from local tests to a real delivery pipeline: continuous integration fundamentals, push and pull-request quality gates, lint, type-check, unit, component and end-to-end gates, dependency caching, matrix builds, artifacts and checksums, secrets and supply-chain security, release promotion, staging and production, rollback and observability.

advanced · about 40 minutes · 4 exercises

  • Explain
  • Implement
  • Debug
  • Test

What you will be able to do

#
  • Install browser binaries before running e2e tests.
  • Start the application deterministically instead of sleeping.
  • Explain how retries can hide real defects.

Overview

#

End-to-end tests exercise the whole system

An end-to-end test drives a real browser against a running application. It exercises routing, rendering, network and state together, which unit and component tests cannot. The cost is speed and stability: browsers are heavy, startup is slow and small timing differences cause flakiness.

snippet.yaml
jobs:
  e2e:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: corepack enable && pnpm install --frozen-lockfile
      - run: npx playwright install --with-deps chromium
      - run: pnpm build
      - run: pnpm test:e2e

Install the browser before the test

Playwright needs its browser binaries. Running playwright test before playwright install fails with a missing-browser error. The --with-deps flag also installs the system libraries the browser needs on a bare runner.

Start the app deterministically

The test runner should start the application itself, wait until it is reachable, then run the tests. A hard-coded sleep is not a readiness check. Use the runner's web-server option, which polls the URL and only proceeds when the app responds.

Retries hide defects

A retry can turn an intermittent failure into a green run. That is useful for genuine infrastructure blips but dangerous as a habit: it hides real race conditions and slow assertions. Track flaky tests and fix the cause instead of raising the retry count.

Traces and artifacts

When an end-to-end test fails, the useful evidence is a trace, a screenshot and the console log. Configure the runner to capture these on failure and upload them as artifacts so the failure can be diagnosed without reproducing it locally.

Sandbox boundary

The browser sandbox cannot launch a native Playwright browser or a hosted runner. It can run the application's JavaScript, but it cannot perform the end-to-end orchestration that a CI job performs.

Exercises

#

Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.

  1. Exercise 1Implement

    Add an e2e job that installs the Chromium browser with system dependencies, builds the app and runs the end-to-end tests.

    starter.yaml
    jobs:
      e2e:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
    

    Reveal the reference answer
    reference.yaml
    jobs:
      e2e:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4
          - uses: actions/setup-node@v4
            with:
              node-version: 20
          - run: corepack enable && pnpm install --frozen-lockfile
          - run: npx playwright install --with-deps chromium
          - run: pnpm build
          - run: pnpm test:e2e

    Authored expected output: An e2e job that installs the browser and dependencies, builds and runs the tests.

    Installing the browser before the test avoids the missing-browser failure. Building first ensures the tests run against the production bundle.

  2. Exercise 2Debug

    This e2e job fails with a missing-browser error. Fix the step order.

    starter.yaml
          - run: pnpm test:e2e
          - run: npx playwright install --with-deps chromium
    

    Reveal the reference answer
    reference.yaml
          - run: npx playwright install --with-deps chromium
          - run: pnpm test:e2e

    Authored expected output: The browser install runs before the test command.

    Steps run in order. Installing the browser after the test means the test runs with no browser available.

  3. Exercise 3Test

    Write a function e2eConfigured(config) that returns true only when config has a baseURL string and a webServer object.

    starter.javascript
    function e2eConfigured(config) {
      // return true or false
    }

    Reveal the reference answer
    reference.javascript
    function e2eConfigured(config) {
      if (!config || typeof config !== 'object') return false;
      const hasBase = typeof config.baseURL === 'string' && config.baseURL.length > 0;
      const hasServer = config.webServer && typeof config.webServer === 'object';
      return hasBase && Boolean(hasServer);
    }

    Authored expected output: e2eConfigured({ baseURL: 'http://localhost:3000', webServer: {} }) is true; a config missing webServer is false.

    The check mirrors the two things a deterministic e2e run needs: a known base URL and a runner-managed server. It is a structural check, not a browser launch.

  4. Exercise 4Explain

    Explain why end-to-end tests are slower and flakier than unit tests, and how retries can hide real defects.

    Reveal the reference answer
    reference.text
    End-to-end tests start a browser and a server, drive real rendering and network, and depend on timing, so they are slower and more sensitive to small delays than pure unit tests. A retry can turn a real race condition or a slow assertion into a green run, hiding the defect instead of surfacing it.

    Authored expected output: A correct answer links speed and flakiness to real browser and network behavior and warns that retries mask races.

    The value of an e2e test is realism; the cost is timing sensitivity. Retries trade signal for green, which is why flaky tests should be fixed, not retried.

Common misconceptions

#
  • A sleep is a reliable way to wait for the app.
  • Retries make an e2e suite reliable.
  • A hosted runner is the same as the browser sandbox.

Follow-up practice

#
  • cicd-08-dependency-caching

Related resources

#

Your progress

#

Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.

Verification: authored. Answers and outputs on this page are authored reference material, not executed results.

© 2026 FrontendX. All rights reserved.