Plugin System
Glubean’s plugin system lets you extend test capabilities without changing the core SDK.
Purpose
- Encapsulate reusable clients/configuration
- Keep initialization lazy and runtime-safe
- Share typed utilities across many test files
How it works
- Define a plugin factory with
definePlugin(...). - Register it in
configure({ plugins: { ... } }). - Consume the plugin instance in tests.
The plugin instance is lazily created on first access.
Custom plugin example
import { configure, definePlugin, test } from "@glubean/sdk";
const myClient = (opts: { endpointKey: string }) =>
definePlugin((runtime) => {
const baseUrl = runtime.requireVar(opts.endpointKey);
return {
getStatus: async () => runtime.http.get(`${baseUrl}/status`).json(),
};
});
const { api } = configure({
plugins: {
api: myClient({ endpointKey: "INTERNAL_API_URL" }),
},
});
export const health = test("internal-health", async (ctx) => {
const status = await api.getStatus();
ctx.expect(status.ok).toBe(true);
});First-party plugins
Notes
- Plugin factories receive
GlubeanRuntimewith access toruntime.http,runtime.requireVar,runtime.requireSecret, andruntime.resolveTemplate. - Reserved keys (
vars,secrets,http) cannot be used as plugin names inconfigure({ plugins }).
Last updated on