Skip to content

Testing mocking a store, Error: You must configure the createSpy option. #1096

Closed Answered by mpont91
mpont91 asked this question in Help and Questions
Discussion options

You must be logged in to vote

I finally solved my problem.

I think that because I'm not using Jest, i need to provide a createSpy parameter when I use createTestingPinia plugin.

So the solution is, first import fn from vitest:

import { describe, expect, it, vi } from 'vitest'

Then inject inside createTestingPinia:

        plugins: [
          createTestingPinia({
            createSpy: vi.fn,
          }),
        ]

It seems easy now, but I was completely lost at the moment... I think it should be on the documentation because now it's the default scaffold when you init a Vue3 project.

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
2 replies
@mpont91
Comment options

@mpont91
Comment options

Comment options

You must be logged in to vote
8 replies
@tulioFcastro
Comment options

@nerdstrike
Comment options

@bylmzio
Comment options

@Fish-century
Comment options

@CriPstian
Comment options

Answer selected by mpont91
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
9 participants
Converted from issue

This discussion was converted from issue #1094 on February 26, 2022 00:23.