From 394f6553d13f2b46c6e52a68145c24699b98e7fa Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sat, 25 Jan 2025 10:14:29 +0100 Subject: [PATCH] feat(testing): warn about incorrect createSpy See #2896 --- packages/testing/src/testing.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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' ) } -- 2.47.3