[Vuejs]-Vue Comonpent test using cypress, getActivePinia was called with no active Pinia

3👍

In the test there is no connection between the app you created that uses Pinia and the Test component you are mounting, hence the error.

Try creating a custom mount command as per the example Replicating Plugins

import { createPinia } from 'pinia' // or Vuex
import { mount } from 'cypress/vue'
import { h } from 'vue'

Cypress.Commands.add('mount', (component, ...args) => {
  args.global = args.global || {}
  args.global.plugins = args.global.plugins || []
  args.global.plugins.push(createPinia())

  return mount(() => {
    return h(VApp, {}, component)
  }, ...args)
})

describe('for example', () => {
  it('render', () => {
    mount(Test);
  });
})

Leave a comment