Skip to content
Discussion options

You must be logged in to vote

It's

const wrapper = mount(MyComponent, { global: { plugins: [ createTestingPinia({ createSpy: fn }) ] }, props: {} })

If you don't create a pinia for each test, each test will share the same state object, ending up in unexpected problems. My recommendation is to wrap the whole mount() call within a function:

describe('my test', () => {
  function factory(propsOrOptions) {
    return mount(MyComponent, { global: { plugins: [ createTestingPinia({ createSpy: fn }) ] }, props: {} })
  }
})

Adapt the argument to pass options to the component

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@miquelromero
Comment options

@madebyfabian
Comment options

@mayacoda
Comment options

@posva
Comment options

posva Jan 4, 2023
Maintainer

Answer selected by madebyfabian
Comment options

You must be logged in to vote
1 reply
@mraichelson
Comment options

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
7 participants
Converted from issue

This discussion was converted from issue #1098 on February 28, 2022 09:44.