Shipeasy

Testing

Build a no-network client with forTesting() and seed every entity with overrides — unit-test flag-gated code without touching the network.

Production readyOn this page · 4 min readUpdated · June 19, 2026Works with · @shipeasy/sdk · server + client

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*.

Test the Engine directly

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 default

Browser (vanilla JS — no React)

import { Engine } from "@shipeasy/sdk/client";

const engine = Engine.forTesting();
engine.overrideFlag("new_checkout", true);
engine.getFlag("new_checkout"); // true

The 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 evaluation
Two ways to mock

Use 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.

Was this page helpful?
✎ Edit this page

On this page