Skip to main content

Plugin Testing

Reference for test utilities, patterns, and lint enforcement for Velaclaw plugins.
Looking for test examples? The how-to guides include worked test examples: Channel plugin tests and Provider plugin tests.

Test utilities

Import: velaclaw/plugin-sdk/testing The testing subpath exports a narrow set of helpers for plugin authors:

Common exports

Types

The testing subpath also re-exports types useful in test files:

Testing target resolution

Target resolution tests should live with your plugin and cover your channel’s supported target syntax, allowFrom behavior, and error cases:

Testing patterns

Unit testing a channel plugin

Unit testing a provider plugin

Mocking the plugin runtime

For code that uses createPluginRuntimeStore, mock the runtime in tests:

Testing with per-instance stubs

Prefer per-instance stubs over prototype mutation:

Contract tests (in-repo plugins)

Bundled plugins have contract tests that verify registration ownership:
These tests assert:
  • Which plugins register which providers
  • Which plugins register which speech providers
  • Registration shape correctness
  • Runtime contract compliance

Running scoped tests

For a specific plugin:
For contract tests only:

Lint enforcement (in-repo plugins)

Three rules are enforced by pnpm check for in-repo plugins:
  1. No monolithic root importsvelaclaw/plugin-sdk root barrel is rejected
  2. No direct src/ imports — plugins cannot import ../../src/ directly
  3. No self-imports — plugins cannot import their own plugin-sdk/<name> subpath
External plugins are not subject to these lint rules, but following the same patterns is recommended.

Test configuration

Velaclaw uses Vitest with V8 coverage thresholds. For plugin tests:
If local runs cause memory pressure: