Test without the internet
mockProvider answers in memory. Your tests never call TypeSafe.
mockProvider is part of the public API. Use it in your app tests so you do not spend keys or wait on the network.
A tiny test
import { createEDcheck, mockProvider, semantic } from "@edteam/edcheck"; const provider = mockProvider({ answers: { fullName: 0.12 },}); const bound = createEDcheck({ provider }).define(User, { rules: { fullName: semantic("A plausible full name for a real person"), },}); const result = await bound.safeParse({ fullName: "asdfasdf" }); // 0.12 is below 0.7 → failexpect(result.success).toBe(false);expect(result.issues[0]?.ruleId).toBe("fullName");How the answer is chosen
answersis aruleId → numbermap (for yes/no rules) or a function.- If there is no answer for that rule, it uses
defaultAnswer(default0.9, meaning “pass”). - For score rules, the mock picks a level from what you configure.
Other useful options
| Option | What it is for |
|---|---|
delayMs | Waits a bit. Useful to test cancel. |
error | Throws an EDcheckProviderError. Useful to test the open/closed policy. |
model | The name you will see on the issue. Default mock. |
The mock stores every request in provider.calls. You can assert which questions were built, without looking at the network.
expect(provider.calls).toHaveLength(1);expect(Object.keys(provider.calls[0]!.questions)).toContain("fullName");