In this lab you will combine the practice project's tests and syntax check into one repeatable command. You will then prove that the command fails when the original bug returns in a disposable copy. The final evidence is both a passing check for the repaired project and a failing check for a known regression.

Before you start

Complete review and handoff. Your project must have a reviewed implementation and passing tests. Estimated time: 15–25 minutes. This lab runs locally and does not need CI credentials or a deployment target.

1. Ask for a deterministic quality command

Add a quality script to package.json that runs npm test and then
npm run check, stopping if either command fails. Keep existing scripts.
Do not add dependencies or external service calls.
Run npm run quality and report its exit result.

The relevant scripts should include:

{
  "test": "node --test",
  "check": "node --check src/tasks.js",
  "quality": "npm test && npm run check"
}

These are entries inside the existing scripts object, not a replacement for the whole package file.

2. Run the check yourself

npm run quality

Expected: all tests pass and the syntax check succeeds. The command returns success only after both steps complete. A syntax check alone cannot detect the original logic error.

3. Prove it detects a regression

Create a disposable copy outside the project and copy only the fixture files into it:

lab_check_dir=$(mktemp -d)
cp package.json "$lab_check_dir/package.json"
cp -R src test "$lab_check_dir/"
echo "$lab_check_dir"

Open the displayed directory in your editor. In that copy only, temporarily replace completeTask with the original broken implementation:

export function completeTask(tasks, id) {
  return tasks.map(task => ({ ...task, completed: true }));
}

Run the check in the disposable copy:

npm --prefix "$lab_check_dir" run quality

Expected: at least the nonmatching-task regression test fails, and the quality command returns failure. Do not copy the intentionally broken implementation back into your working project.

4. Recheck the real project

npm run quality
git diff --check
git status --short

Expected: the real project still passes. Update HANDOFF.md with the quality command and both observed outcomes. A negative check is useful evidence because it shows the automation can reject a known defect.

Troubleshooting

If the disposable copy passes, confirm you edited its source file and that the test still asserts the nonmatching task stays open. If the real project fails afterward, compare its diff; you may have edited the wrong directory. If the command skips syntax checking after a test failure, that is the intended short-circuit behavior.

Checkpoint and next steps

You have a deterministic command, a passing result for correct behavior, and a failing result for a known regression. Use the reliable automation guide to separate agent execution from validation when integrating a real project with CI. Return to the learning path assessment for an independent feature exercise.