Skip to content

Unit testing of actions and getters with jest #501

Discussion options

You must be logged in to vote

Don't split the store definition and then you can create a pinia:

// pinia-store.spec.ts

import { useGeneralStore } from './pinia-store'

describe("pinia store", () => {
  it("actions", () => {
    const pinia = createPinia()
    const store = useGeneralStore(pinia)
    store.testAction()
    
    expect(store.mockData).toEqual("test")
  })
})

Replies: 1 comment 4 replies

Comment options

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

@posva
Comment options

@Oleksii14
Comment options

@eliasmikkola
Comment options

Answer selected by Oleksii14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants