From 44f0762f93bf6ea389dd47574cbf4172989f616b Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 28 Feb 2022 17:55:39 +0100 Subject: [PATCH] refactor: use vi global --- packages/testing/src/testing.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/testing/src/testing.ts b/packages/testing/src/testing.ts index 3cf136b1..2317d481 100644 --- a/packages/testing/src/testing.ts +++ b/packages/testing/src/testing.ts @@ -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.') -- 2.47.3