Skip to article content
FrontendXLesson 16 / 24

Capstone: Testing the Quality Task Board

Build a working model of automated testing from assertions to unit, component, API, integration, contract and end-to-end tests, then apply it to a single progressive task-board capstone where each milestone adds a real defect, a failing test, a corrected implementation and an expected result.

advanced · about 60 minutes · 6 exercises

  • Predict
  • Explain
  • Implement
  • Debug
  • Test
  • Interview

What you will be able to do

#
  • Apply the full testing spectrum to one continuous application.
  • Write a failing test that reproduces a concrete defect before fixing it.
  • Describe the corrected implementation and the expected result for each milestone.

Overview

#

One application, many kinds of test

The capstone is a single task-board application, not a set of unrelated snippets. It has tasks with a title, a status and a priority, a store that holds them, an API client that syncs them, and a user interface that renders and edits them. Every lesson in this course applies to some part of it, and the tests accumulate instead of being thrown away.

Milestones add a defect and a test

Each milestone introduces a small, realistic defect and the test that catches it. The pattern is always the same: reproduce the defect with a failing test, apply the corrected implementation, confirm the expected result. The project is identified as quality-task-board, and its milestones are quality-task-board-01 through quality-task-board-12. The course references the project; individual exercises name the project rather than a milestone id.

A worked example: the filter defect

Suppose the board has a filter that shows only tasks matching a status. The defect: filtering by done also shows archived tasks because the check uses a truthy status instead of an exact match.

snippet.js
// defect
function filterByStatus(tasks, status) {
  return tasks.filter((task) => task.status);
}

A unit test reproduces it: given one done and one archived task, filtering by done must return only the done task. The test fails against the defect. The corrected implementation compares exactly:

snippet.js
function filterByStatus(tasks, status) {
  return tasks.filter((task) => task.status === status);
}

The expected result is a single-element array containing the done task. The same defect is then covered at the component level (the list renders one row) and, for the critical path, at the end-to-end level (the user selects the filter and sees one card).

Layer the tests deliberately

Unit tests cover the pure functions: filtering, sorting, priority comparison, id generation. Component tests cover rendering and interaction: adding a task, editing a title, toggling a status. Integration tests cover the store and the API client together with the network doubled. End-to-end tests cover the critical journey: create, edit, complete and delete a task. Contract tests would cover the API shape if the backend were a separate service.

Environment capability, stated honestly

Unit, component and integration tests run in a Node or browser test environment with the project's runner. End-to-end tests need a real browser and a running application, so they run locally or in CI, not inside an in-browser sandbox. The capstone labels each milestone's tests with the environment that can actually run them. A milestone that claims to launch native browser automation from a sandbox is mislabeled and must be corrected.

What a complete milestone contains

Each milestone states the defect in plain language, the failing test that reproduces it, the corrected implementation, the expected result, and the environment that runs the test. That is the same evidence a reviewer needs to accept the work, which is why the capstone doubles as a template for real projects.

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 1Predict

    With the defective `filterByStatus`, what does filtering by 'done' return for `[{status:'done'},{status:'archived'}]`?

    Read the code, then choose the best answer. The reference explanation stays hidden until you respond.
    stimulus.javascript
    function filterByStatus(tasks, status) {
      return tasks.filter((task) => task.status);
    }
    console.log(filterByStatus([{ status: 'done' }, { status: 'archived' }], 'done').length);
    Choose the best answer
  2. Exercise 2Explain

    Explain why the capstone layers the same defect across unit, component and end-to-end tests.

    Reveal the reference answer
    reference.javascript
    Each layer catches a different class of failure. The unit test proves the filter logic is correct in isolation and fails fast. The component test proves the filtered result reaches the rendered list. The end-to-end test proves the user can select the filter and see the correct cards, covering routing and wiring. Layering gives fast, precise feedback at the bottom and confidence in the whole journey at the top, which is the testing trophy shape.

    The answer should connect each layer to the class of defect it catches and justify the layering by feedback speed and confidence.

    This exercise is part of the course capstone project. Open the capstone section below to load the authored project in the browser-local playground.

  3. Exercise 3Implement

    Implement the corrected `filterByStatus(tasks, status)` so it returns only tasks whose status matches exactly. `console.log(filterByStatus([{status:'done'},{status:'archived'}], 'done').length)` should print `1`.

    starter.javascript
    function filterByStatus(tasks, status) {
      return tasks.filter((task) => task.status);
    }

    Reveal the reference answer
    reference.javascript
    function filterByStatus(tasks, status) {
      return tasks.filter((task) => task.status === status);
    }

    Authored expected output: 1

    Comparing task.status to the requested status exactly keeps only matching tasks. The archived task is excluded, so the result length is 1.

    This exercise is part of the course capstone project. Open the capstone section below to load the authored project in the browser-local playground.

  4. Exercise 4Debug

    The board loses the edited task's other fields because the update replaces the whole task with the edited fields only. Fix the update so it merges, so `console.log(...)` prints `merged`.

    starter.javascript
    function updateTask(tasks, id, changes) {
      return tasks.map((task) => (task.id === id ? { id: task.id, ...changes } : task));
    }
    const tasks = [{ id: 1, title: 'a', status: 'todo', priority: 'high' }];
    const updated = updateTask(tasks, 1, { title: 'b' });
    console.log(updated[0].status === 'todo' && updated[0].title === 'b' ? 'merged' : 'lost');

    Reveal the reference answer
    reference.javascript
    function updateTask(tasks, id, changes) {
      return tasks.map((task) => (task.id === id ? { ...task, ...changes } : task));
    }
    const tasks = [{ id: 1, title: 'a', status: 'todo', priority: 'high' }];
    const updated = updateTask(tasks, 1, { title: 'b' });
    console.log(updated[0].status === 'todo' && updated[0].title === 'b' ? 'merged' : 'lost');

    Authored expected output: merged

    The defective version builds a new object from id and the changes, dropping fields like status and priority. Spreading the existing task first and then the changes preserves untouched fields and applies the edit, which is the expected merge behavior.

    This exercise is part of the course capstone project. Open the capstone section below to load the authored project in the browser-local playground.

  5. Exercise 5Test

    Write the failing-then-passing unit test for the filter defect, then the corrected filter, and prove the expected result.

    starter.javascript
    function filterByStatus(tasks, status) {
      return tasks.filter((task) => task.status === status);
    }

    Reveal the reference answer
    reference.javascript
    function assertEqual(actual, expected, label) {
      if (actual !== expected) throw new Error(label + ': expected ' + expected + ' but got ' + actual);
    }
    const tasks = [{ id: 1, status: 'done' }, { id: 2, status: 'archived' }];
    const result = filterByStatus(tasks, 'done');
    assertEqual(result.length, 1, 'only done tasks');
    assertEqual(result[0].id, 1, 'correct task kept');
    console.log('filter milestone verified');

    Authored expected output: filter milestone verified

    Against the defect this test fails because the length is 2. Against the corrected filter it passes. The assertions check both the count and the identity of the kept task, so the test pins the exact expected result.

    This exercise is part of the course capstone project. Open the capstone section below to load the authored project in the browser-local playground.

  6. Exercise 6Interview

    In an interview, describe how you would present the capstone as evidence of your testing skill.

    Reveal the reference answer
    reference.javascript
    I would show one milestone end to end: the defect in plain language, the failing test that reproduces it, the corrected implementation and the expected result, then name the environment that runs each test. I would explain why the filter logic is a unit test, why the rendered list is a component test and why the user journey is an end-to-end test. I would be explicit that browser end-to-end tests run in CI, not in a sandbox, because mislabeling capability is itself a defect.

    The answer should demonstrate the defect-to-fix loop, layer justification, and honest environment labeling.

    This exercise is part of the course capstone project. Open the capstone section below to load the authored project in the browser-local playground.

Capstone project

#

The capstone opens the authored project in the browser-local playground. Milestones labeled native-ci or local-node cannot run in the browser sandbox: they open their files only, and their expected logs are authored expectations, not captured runs.

Loading the capstone project...

Common misconceptions

#
  • The capstone is a set of independent exercises rather than one application.
  • A milestone is complete when the code is written, not when the test passes.
  • Browser end-to-end tests can run inside the in-browser sandbox.

Follow-up practice

#
  • testing-ci-gates
  • testing-test-strategy

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.