Script Valley
Debugging: A Systematic Approach
Testing as a Debugging Tool/Assessment

Practice & Assessment

Test your understanding of Testing as a Debugging Tool

Multiple Choice Questions

5
1

You write a test for a bug fix and it passes immediately without changing any code. What does this mean?

2

A function fails on a 10,000-item dataset. What is the most efficient first step to isolate the bad input?

3

A test fails intermittently and you discover one test modifies a global array that another test reads. What is the correct fix?

4

What does a property-based test check that an example-based test does not?

5

What is the correct action when a flaky test is blocking your CI pipeline but you do not have time to fix it right now?

Coding Challenges

1
1

Write Tests to Fix and Prevent Three Bugs

A provided JavaScript module contains three known bugs described in comments: (1) a string-to-number coercion issue, (2) an off-by-one in an array slice, (3) a missing null check. For each bug: write a failing test that proves the bug, fix the function until the test is green, and add one additional regression test covering a boundary case near the fault. Input: provided module file and test file scaffold. Output: completed test file with 6 tests (3 bug tests and 3 regression tests), all passing. Time estimate: 30 minutes.

Medium

Mini Project

1

Regression Test Suite for a Buggy Utility Library

Given a provided utility library with 6 functions (string manipulation, array operations, and date formatting), create a complete regression test suite using Jest or Node built-in assert. Requirements: identify and document at least one bug per function, write a failing test for each bug before fixing it, fix each function, add boundary-condition regression tests for each fix, run the suite and confirm all tests pass, and produce a written summary of each bug found with its root cause and the test that pins it. Total tests: minimum 12.

Hard