Collects mock plugin definitions and real plugins, produces the
IPlugin[] for createTestApp, and resets between tests.
Integration tests that mock several capabilities at once (e.g.
database + cache + logger) build the plugin array via
FixtureManager so afterEach(() => fixtures.reset()) is the
only teardown needed.
Example 1
Example 1
import { FixtureManager, createTestApp } from '@setu-ts/testing'; import { RuntimePlugin } from '@setu-ts/runtime'; const fixtures = new FixtureManager(); beforeEach(async () => { fixtures .mock('database', { query: () => [] }) .mock('cache', { get: () => null, set: () => {} }); const app = await createTestApp({ plugins: [RuntimePlugin(), ...fixtures.plugins()], }); }); afterEach(() => fixtures.reset());
mock(name: string,service: object,options?: { provides?: string; priority?: number; }): this
Registers a mock service under a capability token.
plugin(plugin: IPlugin): this
Stores a real plugin.
plugins(): IPlugin[]
Returns all plugins in true insertion order.
reset(): void
Clears the store. Call in afterEach to reset between tests.