入门指南
核心概念
服务端渲染
开发者指南
- Migrating from Vuex ≤4
- HMR (Hot Module Replacement)
- 测试存储商店
- Usage without setup()
- Composing Stores
- Migrating from 0.x (v1) to v2
API 手册
- API Documentation
- Module: pinia
- Module: @pinia/nuxt
- Module: @pinia/testing
- Enumeration: MutationType
- Interface: TestingOptions
- Interface: DefineSetupStoreOptions
- Interface: DefineStoreOptions
- Interface: DefineStoreOptionsBase
- Interface: DefineStoreOptionsInPlugin
- Interface: MapStoresCustomization
- Interface: Pinia
- Interface: PiniaCustomProperties
- Interface: PiniaCustomStateProperties
- Interface: PiniaPlugin
- Interface: PiniaPluginContext
- Interface: StoreDefinition
- Interface: StoreProperties
- Interface: SubscriptionCallbackMutationDirect
- Interface: SubscriptionCallbackMutationPatchFunction
- Interface: SubscriptionCallbackMutationPatchObject
- Interface: _StoreOnActionListenerContext
- Interface: _StoreWithState
- Interface: _SubscriptionCallbackMutationBase
- Interface: TestingPinia
Interface: TestingOptions
@pinia/testing.TestingOptions
Properties
createSpy
• Optional
createSpy: (fn?
: (...args
: any
[]) => any
) => (...args
: any
[]) => any
Type declaration
▸ (fn?
): (...args
: any
[]) => any
Function used to create a spy for actions and $patch()
. Pre-configured with jest.fn()
in jest projects or vi.fn()
in vitest projects.
Parameters
Name | Type |
---|---|
fn? | (...args : any []) => any |
Returns
fn
▸ (...args
): any
Parameters
Name | Type |
---|---|
...args | any [] |
Returns
any
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.
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.
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.
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()
.
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()
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论