Skip to content

Use sandboxes and run tests in CI

Each sandbox has its own keys, service data, and webhook destinations. Use separate sandboxes when several developers or branches share a running instance. Use --memory or an in-memory library instance when each test run should start clean.

Use the sandbox menu in the dashboard, or create it with the CLI from a Lookalyke checkout.

Terminal window
node packages/server/dist/cli.js sandbox new feature-x
node packages/server/dist/cli.js env stripe --sandbox feature-x

Apply the new sandbox’s key and webhook settings to the branch’s development configuration. Before resetting a shared sandbox, check which sandbox is selected. A reset returns its data to its starting state.

After building Lookalyke, save this as stripe-smoke.test.mjs at the root of the product checkout. The test starts its own server on a free port, checks a real HTTP response, and stops the server even if the assertion fails.

import assert from "node:assert/strict";
import test from "node:test";
import { start } from "./packages/server/dist/index.js";
test("Stripe customers can be listed", async () => {
const lk = await start({
memory: true,
port: 0,
apps: ["stripe"],
quiet: true,
});
try {
const response = await fetch(`${lk.url}/stripe/v1/customers`, {
headers: { Authorization: `Bearer ${lk.sandbox.secretKey}` },
});
assert.equal(response.status, 200);
assert.equal((await response.json()).object, "list");
} finally {
await lk.stop();
}
});

Run node --test stripe-smoke.test.mjs. To import the same start function from lookalyke in your own project, build a package tarball from the product checkout and install it in that project.

Run an existing test suite against the CLI

Section titled “Run an existing test suite against the CLI”

Start the built CLI with --memory --apps stripe and choose a free port if multiple jobs share a machine. Wait for /_lookalyke/health to return "ok": true, then pass the instance URL and sandbox credentials to your test process. Stop the CLI in the job’s cleanup step. If you choose a port other than 4100, pass its URL to CLI commands that talk to the running instance.