From: Eduardo San Martin Morote Date: Sat, 25 Jan 2025 09:14:29 +0000 (+0100) Subject: feat(testing): warn about incorrect createSpy X-Git-Tag: @pinia/nuxt@0.10.0~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=394f6553d13f2b46c6e52a68145c24699b98e7fa;p=thirdparty%2Fvuejs%2Fpinia.git feat(testing): warn about incorrect createSpy See #2896 --- diff --git a/packages/testing/src/testing.ts b/packages/testing/src/testing.ts index 0b4db94f..bb8e48b8 100644 --- a/packages/testing/src/testing.ts +++ b/packages/testing/src/testing.ts @@ -129,7 +129,14 @@ export function createTestingPinia({ /* istanbul ignore if */ if (!createSpy) { throw new Error( - '[@pinia/testing]: You must configure the `createSpy` option.' + '[@pinia/testing]: You must configure the `createSpy` option. See https://pinia.vuejs.org/cookbook/testing.html#Specifying-the-createSpy-function' + ) + } else if ( + typeof createSpy !== 'function' || + 'mockReturnValue' in createSpy + ) { + throw new Error( + '[@pinia/testing]: Invalid `createSpy` option. See https://pinia.vuejs.org/cookbook/testing.html#Specifying-the-createSpy-function' ) }