API Documentation / @pinia/testing / TestingOptions

Interface: TestingOptions

@pinia/testing.TestingOptions

Properties

fakeApp

Optional fakeApp: boolean

Creates an empty App and calls app.use(pinia) with the created testing pinia. This is allows you to use plugins while unit testing stores as plugins will wait for pinia to be installed in order to be executed. Defaults to false.

Defined in

testing/src/testing.ts:45


initialState

Optional initialState: StateTree

Allows defining a partial initial state of all your stores. This state gets applied after a store is created, allowing you to only set a few properties that are required in your test.

Defined in

testing/src/testing.ts:15


plugins

Optional plugins: PiniaPlugin[]

Plugins to be installed before the testing plugin. Add any plugins used in your application that will be used while testing.

Defined in

testing/src/testing.ts:21


stubActions

Optional stubActions: boolean

When set to false, actions are only spied, they still get executed. When set to true, actions will be replaced with spies, resulting in their code not being executed. Defaults to true. NOTE: when providing createSpy(), it will only make the fn argument undefined. You still have to handle this in createSpy().

Defined in

testing/src/testing.ts:30


stubPatch

Optional stubPatch: boolean

When set to true, calls to $patch() won't change the state. Defaults to false. NOTE: when providing createSpy(), it will only make the fn argument undefined. You still have to handle this in createSpy().

Defined in

testing/src/testing.ts:37

Methods

createSpy

Optional createSpy(fn?): (...args: any[]) => any

Function used to create a spy for actions and $patch(). Pre-configured with jest.fn() in jest projects.

Parameters

NameType
fn?(...args: any[]) => any

Returns

fn

▸ (...args): any

Parameters
NameType
...argsany[]
Returns

any

Defined in

testing/src/testing.ts:51