From: Thomas Kint Date: Thu, 20 Jan 2022 11:56:55 +0000 (+0100) Subject: add pre-configuration for vitest X-Git-Tag: @pinia/testing@0.0.10~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e4638ef34c16487b2f35b0de09800f6dcfd5a980;p=thirdparty%2Fvuejs%2Fpinia.git add pre-configuration for vitest --- diff --git a/packages/testing/src/testing.ts b/packages/testing/src/testing.ts index d891c3a4..ed05940e 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. + * with `jest.fn()` in jest projects or `vitest.fn()` in vitest projects */ createSpy?: (fn?: (...args: any[]) => any) => (...args: any[]) => any } @@ -64,8 +64,8 @@ export interface TestingPinia extends Pinia { * Creates a pinia instance designed for unit tests that **requires mocking** * the stores. By default, **all actions are mocked** and therefore not * executed. This allows you to unit test your store and components separately. - * You can change this with the `stubActions` option. If you are using jest, - * they are replaced with `jest.fn()`, otherwise, you must provide your own + * You can change this with the `stubActions` option. If you are using jest or vitest, + * they are replaced with basic `fn()`, otherwise, you must provide your own * `createSpy` option. * * @param options - options to configure the testing pinia @@ -89,7 +89,7 @@ export function createTestingPinia({ plugins.forEach((plugin) => pinia.use(plugin)) - const createSpy = _createSpy || (typeof jest !== 'undefined' && jest.fn) + const createSpy = _createSpy || (typeof jest !== 'undefined' && jest.fn) || (typeof vitest !== 'undefined' && vitest.fn) /* istanbul ignore if */ if (!createSpy) { throw new Error('You must configure the `createSpy` option.')