AI MOOC
✦ Grow togetherInvite 3 friends, earn 1 month of membership · Up to 12 monthsInvite friends →

Library / My reading notes

Deliver tests and a review note

Record normal, boundary and error checks and state the feature’s scope.

Back to course plan: Build a small feature you can verify with AI

Chapter 3 / 3 · Read and take notes

Record normal, boundary and error checks and state the feature’s scope.

Understand the method

Use independently determined expectations instead of duplicating the implementation formula. Fixed, manually calculated values work here: 10000, 9002 and 0. Error tests check the error type. Re-run the original failing case after the fix.

A delivery note records scope, observed tests and limitations. This function does not implement tax, refunds, inventory, order state or currency conversion. Payment integration would need its own server-side checks. Report tests you actually ran rather than copying the expected results as observed evidence.

  1. 1Prove failure
  2. 2Repair
  3. 3Retest
  4. 4State limits

Included material

Place the corrected function in a browser console or local .mjs file, then execute the checks below.

Work through the steps

  1. Run three fixed-value assertions and two error checks.
  2. Temporarily change > back to >= to confirm the test detects it, then restore it.
  3. Save your actual results and review note.

Worked example

function expect(actual, expected) {
  if (actual !== expected) throw new Error(`${actual} != ${expected}`);
}
function expectRangeError(fn) {
  try { fn(); } catch (e) {
    if (e instanceof RangeError) return;
    throw e;
  }
  throw new Error("Expected RangeError");
}
expect(fee(5000, 2), 10000);
expect(fee(5001, 2), 9002);
expect(fee(0, 1), 0);
expectRangeError(() => fee(1, 0));
expectRangeError(() => fee(Number.MAX_SAFE_INTEGER, 2));

Your exercise

Add tests for a fraction, a negative value and a string. Write three sentences about the defect, fix and checks you actually ran.

Check before delivery

  • The test fails on the defective version and passes after repair.
  • The note does not describe the exercise as a deployed payment system.
Finish the exercise, then view the reference

Use fee(1.5,1), fee(-1,1) and fee(1,"2"); each should throw RangeError. Record your environment, date and actual results without claiming complete business coverage.

An original course with teaching exercises. Reading records, practice outcomes and independent certification are distinct.

References and further reading

The lessons are original. The following sources are provided under their respective permissions.

Course

Mastering GitHub Copilot

Microsoft / Anthony Bartolo · en/zh

MIT

License checked. This entry links to the original; the book text is not mirrored.

License checked: 2026-10-16 · Pinned 49137b58
Course

Generative AI with JavaScript

Microsoft · en/zh

MIT

License checked. This entry links to the original; the book text is not mirrored.

License checked: 2026-10-16 · Pinned 03e41953