Skip to content

Commit e4638ef

Browse files
tkintposva
authored andcommitted
add pre-configuration for vitest
1 parent 94c9c7b commit e4638ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/testing/src/testing.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface TestingOptions {
4646

4747
/**
4848
* Function used to create a spy for actions and `$patch()`. Pre-configured
49-
* with `jest.fn()` in jest projects.
49+
* with `jest.fn()` in jest projects or `vitest.fn()` in vitest projects
5050
*/
5151
createSpy?: (fn?: (...args: any[]) => any) => (...args: any[]) => any
5252
}
@@ -64,8 +64,8 @@ export interface TestingPinia extends Pinia {
6464
* Creates a pinia instance designed for unit tests that **requires mocking**
6565
* the stores. By default, **all actions are mocked** and therefore not
6666
* executed. This allows you to unit test your store and components separately.
67-
* You can change this with the `stubActions` option. If you are using jest,
68-
* they are replaced with `jest.fn()`, otherwise, you must provide your own
67+
* You can change this with the `stubActions` option. If you are using jest or vitest,
68+
* they are replaced with basic `fn()`, otherwise, you must provide your own
6969
* `createSpy` option.
7070
*
7171
* @param options - options to configure the testing pinia
@@ -89,7 +89,7 @@ export function createTestingPinia({
8989

9090
plugins.forEach((plugin) => pinia.use(plugin))
9191

92-
const createSpy = _createSpy || (typeof jest !== 'undefined' && jest.fn)
92+
const createSpy = _createSpy || (typeof jest !== 'undefined' && jest.fn) || (typeof vitest !== 'undefined' && vitest.fn)
9393
/* istanbul ignore if */
9494
if (!createSpy) {
9595
throw new Error('You must configure the `createSpy` option.')

0 commit comments

Comments
 (0)