Skip to Content
SDK (Deep Dive)Plugin System

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

  1. Define a plugin factory with definePlugin(...).
  2. Register it in configure({ plugins: { ... } }).
  3. 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 GlubeanRuntime with access to runtime.http, runtime.requireVar, runtime.requireSecret, and runtime.resolveTemplate.
  • Reserved keys (vars, secrets, http) cannot be used as plugin names in configure({ plugins }).
Last updated on