Open Studio
Kit

Testing

kubb/kit/testing is a separate subpath for the Vitest-backed helpers used to test plugins, generators, and adapters, kept apart from kubb/kit so the authoring toolkit never pulls in Vitest.

kubb/kit/testing is a separate subpath for the Vitest-backed helpers used to test plugins, generators, and adapters. It stays separate from kubb/kit so importing the authoring toolkit never pulls Vitest into a plugin's runtime dependencies.

plugin.test.ts
typescript
import { createMockedPlugin, renderGeneratorOperation, matchFiles } from 'kubb/kit/testing'

The subpath exports mocking builders, generator runners, and a snapshot matcher:

ExportWhat it does
createMockedPluginBuilds a minimal plugin for a test without wiring a full config.
createMockedAdapterBuilds a minimal adapter for a test without wiring a full config. parse returns an empty InputNode by default.
createMockedPluginDriverBuilds a driver around a set of plugins so a generator runs through its real lifecycle in isolation.
renderGeneratorSchemaCalls a generator's schema() method against a SchemaNode fixture and collects the files it emits.
renderGeneratorOperationCalls a generator's operation() method against an OperationNode fixture and collects the files it emits.
renderGeneratorOperationsCalls a generator's operations() method against an array of OperationNode fixtures and collects the files it emits.
matchFilesAsserts the generated FileNodes match expected paths and contents through file snapshots, the assertion most generator tests end on.