Skip to content

Commit 67ddc04

Browse files
committed
docs: match vitest mock
Close #2759, #2796
1 parent 292350f commit 67ddc04

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/docs/cookbook/testing.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ Actions are automatically spied but type-wise, they are still the regular action
172172

173173
```ts
174174
import type { Mock } from 'vitest'
175+
import type { UnwrapRef } from 'vue'
175176
import type { Store, StoreDefinition } from 'pinia'
176177

177178
function mockedStore<TStoreDef extends () => unknown>(
@@ -187,15 +188,13 @@ function mockedStore<TStoreDef extends () => unknown>(
187188
State,
188189
Record<string, never>,
189190
{
190-
[K in keyof Actions]: Actions[K] extends (
191-
...args: infer Args
192-
) => infer ReturnT
191+
[K in keyof Actions]: Actions[K] extends (...args: any[]) => any
193192
? // 👇 depends on your testing framework
194-
Mock<Args, ReturnT>
193+
Mock<Actions[K]>
195194
: Actions[K]
196195
}
197196
> & {
198-
[K in keyof Getters]: Getters[K] extends ComputedRef<infer T> ? T : never
197+
[K in keyof Getters]: UnwrapRef<Getters[K]>
199198
}
200199
: ReturnType<TStoreDef> {
201200
return useStore() as any

0 commit comments

Comments
 (0)