Skipping and focusing in JavaScript
skip, todo and only, plus the conditional forms.
import test from "node:test";
import assert from "node:assert/strict";
test("skipped by option", { skip: "needs a database" }, () => {
assert.fail("never runs");
});
test("skipped at run time", (t) => {
if (process.platform === "win32") {
t.skip("posix only");
return;
}
assert.ok(process.platform.length > 0);
});
test("not written yet", { todo: true }, () => {
assert.fail("still to do");
});
test("plain and passing", () => assert.ok(true));
How it works
t.skipinside the test decides at run time.todorecords intent without failing the run.onlyneeds the runner's --test-only flag to mean anything.
Keywords and builtins used here
fromifimportreturn
The run, in numbers
- Lines
- 20
- Characters to type
- 448
- Tokens
- 117
- Three-star pace
- 105 tpm
At the three-star pace of 105 tokens a minute, this run takes about 67 seconds.
Step 1 of 2 in Selecting, step 7 of 9 in Testing with node:test.