]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
feat(testing): warn about incorrect createSpy
authorEduardo San Martin Morote <posva13@gmail.com>
Sat, 25 Jan 2025 09:14:29 +0000 (10:14 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Sat, 25 Jan 2025 09:14:29 +0000 (10:14 +0100)
See #2896

packages/testing/src/testing.ts

index 0b4db94f57feadc0b865154197f279da5aea2f86..bb8e48b83b503ddcb8951ae347b77e511bc7977d 100644 (file)
@@ -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'
     )
   }