Plugin Testing
Reference for test utilities, patterns, and lint enforcement for Velaclaw plugins.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 usescreatePluginRuntimeStore, 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:- Which plugins register which providers
- Which plugins register which speech providers
- Registration shape correctness
- Runtime contract compliance
Running scoped tests
For a specific plugin:Lint enforcement (in-repo plugins)
Three rules are enforced bypnpm check for in-repo plugins:
- No monolithic root imports —
velaclaw/plugin-sdkroot barrel is rejected - No direct
src/imports — plugins cannot import../../src/directly - No self-imports — plugins cannot import their own
plugin-sdk/<name>subpath
Test configuration
Velaclaw uses Vitest with V8 coverage thresholds. For plugin tests:Related
- SDK Overview — import conventions
- SDK Channel Plugins — channel plugin interface
- SDK Provider Plugins — provider plugin hooks
- Building Plugins — getting started guide