]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
refactor: use vi global
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 28 Feb 2022 16:55:39 +0000 (17:55 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 28 Feb 2022 16:55:39 +0000 (17:55 +0100)
packages/testing/src/testing.ts

index 3cf136b12feed24121ba249a48465b9fcbf1bacb..2317d481466b10ea896e38f19aef9f405dfb430f 100644 (file)
@@ -46,7 +46,7 @@ export interface TestingOptions {
 
   /**
    * Function used to create a spy for actions and `$patch()`. Pre-configured
-   * with `jest.fn()` in jest projects or `vitest.fn()` in vitest projects.
+   * with `jest.fn()` in jest projects or `vi.fn()` in vitest projects.
    */
   createSpy?: (fn?: (...args: any[]) => any) => (...args: any[]) => any
 }
@@ -60,6 +60,12 @@ export interface TestingPinia extends Pinia {
   app: App
 }
 
+declare var vi:
+  | undefined
+  | {
+      fn: (fn?: (...args: any[]) => any) => (...args: any[]) => any
+    }
+
 /**
  * Creates a pinia instance designed for unit tests that **requires mocking**
  * the stores. By default, **all actions are mocked** and therefore not
@@ -92,7 +98,7 @@ export function createTestingPinia({
   const createSpy =
     _createSpy ||
     (typeof jest !== 'undefined' && jest.fn) ||
-    (typeof vitest !== 'undefined' && vitest.fn)
+    (typeof vi !== 'undefined' && vi.fn)
   /* istanbul ignore if */
   if (!createSpy) {
     throw new Error('You must configure the `createSpy` option.')