1. Built-in runner
test and describe come straight from the node:test built-in module — no Jest or Vitest install needed.
import { test, describe } from "node:test";Typorithm · medium
Step 1 of 8 · intro card
Testing & Debug
node:test is Node's built-in test runner — import { test, describe } from "node:test" and run with node --test. describe groups subtests, test.skip/only filter the run, async tests work by returning a promise, and the node:test mock module (mock.fn, mock.method) handles stubbing.
Node ships a built-in runner in the node:test module, so you import { test, describe } from "node:test" and execute the suite with node --test — no third-party runner required.
describe groups related cases and the test calls nested inside it become subtests; test.skip skips a case while test.only narrows the run to only the marked tests.
An async test is just a function that returns a promise — the runner awaits it and fails if it rejects — and the node:test mock module provides mock.fn and mock.method for stubbing.
import { test, describe } from "node:test"; run with node --test.
describe groups subtests; test.skip/only filter the run.
Async tests return a promise; mock.fn/mock.method stub.
import { test, describe } from "node:test";
describe("math", () => {
test("adds", () => {
if (1 + 1 !== 2) throw new Error("bad");
});
test.skip("later", () => {});
});
test("async", async () => {
await Promise.resolve();
});Connect each part of the code to the concept before you type.
test and describe come straight from the node:test built-in module — no Jest or Vitest install needed.
import { test, describe } from "node:test";describe groups related tests; test calls inside it become subtests of that suite.
describe("math", () => {test.skip marks a test as skipped; test.only restricts the run to just the marked tests.
test.skip("later", () => {});An async test returns a promise; the runner awaits it and fails the test if the promise rejects.
test("async", async () => {Awaiting inside the test lets the runner track completion before reporting pass or fail.
await Promise.resolve();Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.