Skip to content

How to get basic test for component with Pinia working? #1540

Discussion options

You must be logged in to vote

ok, I don't know why I couldn't get the below to work before. But everything seems to work now.

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

import { createTestingPinia } from '@pinia/testing'
import { mount } from '@vue/test-utils'
import { storeToRefs } from 'pinia'
import Create from '@/components/greeting/Create.vue'
import { useGreetingStore } from '@/stores/greeting.js'


describe('Create', () => {
  it('renders properly', async () => {
    const arbitraryMessage = 'arbitrary test greeting'
    const wrapper = mount(Create, {
      global: {
        plugins: [
          createTestingPinia({
            initialState: {
              greeting: {
                greetings: [
        …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by zhao-li
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant