Skip to content

Commit

Permalink
docs: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 29, 2024
1 parent 7218691 commit 4a743fb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/docs/cookbook/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ beforeEach(() => {
title="Watch a free video of Mastering Pinia about testing stores"
/> -->


This can be achieved with `createTestingPinia()`, which returns a pinia instance designed to help unit tests components.

Start by installing `@pinia/testing`:
Expand Down Expand Up @@ -214,6 +213,8 @@ const store = mockedStore(useSomeStore)
store.someAction.mockResolvedValue('some value')
```

If you are interesting in learning more tricks like this, you should check out the Testing lessons on [Mastering Pinia](https://masteringpinia.com/lessons/exercise-mocking-stores-introduction).

### Specifying the createSpy function

When using Jest, or vitest with `globals: true`, `createTestingPinia` automatically stubs actions using the spy function based on the existing test framework (`jest.fn` or `vitest.fn`). If you are not using `globals: true` or using a different framework, you'll need to provide a [createSpy](/api/interfaces/pinia_testing.TestingOptions.html#createspy) option:
Expand Down

0 comments on commit 4a743fb

Please sign in to comment.