The error you are encountering is likely due to the fact that you are not providing the propsData option correctly when mounting the component.

Here is the corrected code:

import { mount } from '@vue/test-utils'
import NavBox from '../NavBox.vue'

describe('NavBox', () => {
  test('is a Vue instance', () => {
    const wrapper = mount(NavBox, {
      propsData: {
        nav: {}
      }
    })
    expect(wrapper).toBeTruthy()
  })
})

In the above code, the propsData option is used to pass the nav prop to the NavBox component. By providing the propsData option correctly, the error should be resolved.

vue中执行单元测试报错:import mount from vuetest-utilsimport NavBox from NavBoxvuedescribeNavBox = testis a Vue instance = const wrapper = mountNavBox nav expectwrappertoBeTruthy

原文地址: https://www.cveoy.top/t/topic/hPRX 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录