Concepts

Coverage versus assertion strength

Try the free JavaScript compiler

An assertion may execute the code yet fail to distinguish correct from incorrect outputs. This example demonstrates a weak test passing on a wrong value.

Formal Syntax & Structure

javascript syntaxjavascript
assert.ok(result.length > 0)

Working Example

Example Snippetjavascript
(async () => {const assert=require("node:assert/strict");const wrong=[99];assert.ok(wrong.length>0);console.log(wrong[0]===2,"weak test passed");})()
JavaScript Reference