From: Eduardo San Martin Morote Date: Mon, 28 Feb 2022 16:55:39 +0000 (+0100) Subject: refactor: use vi global X-Git-Tag: @pinia/testing@0.0.10~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=44f0762f93bf6ea389dd47574cbf4172989f616b;p=thirdparty%2Fvuejs%2Fpinia.git refactor: use vi global --- 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.')