| title | Testing |
|---|---|
| description | Checking and testing strategies, processes, and test pages. |
This section contains checking and testing strategies, processes, and test pages used by website tests and deployed live checks.
This section is under construction.
When a test fails, the output should make it obvious what was being checked and show a clear diff between actual and expected values, without long hand-written messages.
For example, avoid:
assert.ok(a === b, `expected ${a} to be ${b}`);Instead favor:
assert.strictEqual(status, expectedStatus, 'HTTP status');The points below use Node's built-in node:test runner and assert API because
that is what several of our test suites use. The same ideas apply in other test
frameworks: prefer assertions that produce tight diffs, keep failure context
short and specific, and extract shared helpers when the same check repeats.
- Prefer
assert.strictEqualoverassert.equalfor primitive checks where strictness and diff quality matter. - Add a short third argument as context, for example
HTTP status,Content-Type,Location,Request body. - Use
assert.matchwhen a regular expression can capture the intent more clearly thanincludesor chainedoklogic. - Put shared assertion helpers in a module imported by the test suites that use
them, colocated with those tests instead of copy-pasted across files. Other
small, test-only utilities can live in the same module when it stays focused
(for example
assertVaryIncludesAcceptinnetlify/edge-functions/lib/test-helpers.ts).