From: Eduardo San Martin Morote Date: Wed, 9 Oct 2024 09:43:37 +0000 (+0200) Subject: docs: match vitest mock X-Git-Tag: @pinia/nuxt@0.6.0~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=67ddc04453e8fcc6d6eded47b37128fe938a1ce5;p=thirdparty%2Fvuejs%2Fpinia.git docs: match vitest mock Close #2759, #2796 --- diff --git a/packages/docs/cookbook/testing.md b/packages/docs/cookbook/testing.md index b7bc381a..657ae7b4 100644 --- a/packages/docs/cookbook/testing.md +++ b/packages/docs/cookbook/testing.md @@ -172,6 +172,7 @@ Actions are automatically spied but type-wise, they are still the regular action ```ts import type { Mock } from 'vitest' +import type { UnwrapRef } from 'vue' import type { Store, StoreDefinition } from 'pinia' function mockedStore unknown>( @@ -187,15 +188,13 @@ function mockedStore unknown>( State, Record, { - [K in keyof Actions]: Actions[K] extends ( - ...args: infer Args - ) => infer ReturnT + [K in keyof Actions]: Actions[K] extends (...args: any[]) => any ? // 👇 depends on your testing framework - Mock + Mock : Actions[K] } > & { - [K in keyof Getters]: Getters[K] extends ComputedRef ? T : never + [K in keyof Getters]: UnwrapRef } : ReturnType { return useStore() as any