Unit testing
suggest changeChoose a maintained test runner that can transform TypeScript directly or through a configured build step. Transformation commonly removes types without checking them, so keep type checking separate from test execution and report both kinds of failure clearly:
{
"scripts": {
"typecheck": "tsc --noEmit",
"test": "vitest run"
}
}
Test public behavior, and use satisfies when fixture objects should be checked without losing their inferred literal types.
interface User {
id: string;
active: boolean;
}
const fixture = { id: "user-1", active: true } satisfies User;
console.log(fixture.id);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents