Testing
Build a no-network client with forTesting() and seed every entity with overrides — unit-test flag-gated code without touching the network.
Code that reads flags shouldn't need a live connection to test. forTesting() builds a no-network Engine that's already "ready": init() / initOnce() / identify() are no-ops, track() is a no-op, telemetry is off, and no SDK key is required. You seed values with override*.
The test utilities live on the Engine — the heavyweight client. Everyday flag reads
use configure + new Client(user); here you build an isolated
Engine so a unit test never touches the network.
Server
import { Engine } from "@shipeasy/sdk/server";
const engine = Engine.forTesting();
engine.overrideFlag("new_checkout", true);
engine.overrideConfig("upload_limits", { max_uploads: 50 });
engine.overrideExperiment("hero_cta", "treatment", { primary_label: "Buy now" });
engine.getFlag("new_checkout", { user_id: "u1" }); // true
engine.getConfig("upload_limits"); // { max_uploads: 50 }
engine.getExperiment("hero_cta", { user_id: "u1" }, { primary_label: "Sign up" });
// → { inExperiment: true, group: "treatment", params: { primary_label: "Buy now" } }
engine.track("u1", "purchase"); // no-op — never hits the network
engine.clearOverrides(); // reset every override back to defaultBrowser (vanilla JS — no React)
import { Engine } from "@shipeasy/sdk/client";
const engine = Engine.forTesting();
engine.overrideFlag("new_checkout", true);
engine.getFlag("new_checkout"); // trueThe override API
overrideFlag(name: string, value: boolean): void;
overrideConfig(name: string, value: unknown): void;
overrideExperiment(name: string, group: string, params: Record<string, unknown>): void;
clearOverrides(): void;Overrides on a real client
override* also works on a normal (non-test) Engine — a programmatic override always wins. In the browser the precedence is:
programmatic override > URL / devtools override (?se_gate_… ) > the server's evaluationUse forTesting() + override* to seed individual values; use a
snapshot when you want the real rule set evaluated
offline. They compose — overrides apply on top of a snapshot too.