Broken application · Edition 2

Debug and test

Reproduce a defect, fix it and write a regression test.

Before you begin

Start a browser preview, read the console and make a small JavaScript edit.

The practical problem

A practice counter says one before anyone clicks. To fix the right problem, write down what you observe and how you obtained it before changing the starter.

Build it step by step

  1. Run the starter and note the actual value you see in the console.
  2. Write a test with one expected starting value and one expected value after an increment.
  3. Make the smallest fix that passes both checks, then intentionally reintroduce the old value once to verify your test catches it.

Acceptance criteria

  • The original defect can be reproduced consistently.
  • The corrected start is 0 and the first increment yields 1.
  • The documented test fails when the original defect is reintroduced.

Common mistake

Do not fix the label by hard-coding a displayed zero while leaving the underlying count at one.

How to assess your work

Run the checks below and write down what you expected, what happened, and one change you can demonstrate. Self-checks are practice evidence, not a verified grade.

Build

Start with a local example that displays a count of one when zero is expected. Describe how to reproduce it, then make the smallest correction.

Test

Test the initial value and one increment in the exported project. Write one assertion that would have failed before your change.

Reflect

What made your regression test more useful than a visual check alone?

Starter project and AI hint

The initial value should be zero. Reproduce the bug and write down what you observed.

Give the tutor expected and actual behaviour. Ask for the smallest test that distinguishes them.