У меня есть простой Vue SF C, который отображает компонент с учетом значения проп.
<template>
<component :is="component" v-bind="stepProps" />
</template>
<script>
import { _ } from 'core'
export default {
name: 'SetupFlow',
props: {
type: {
type: String,
required: true
},
step: {
type: String,
required: true
},
stepProps: Object
},
computed: {
component () {
const camelCaseName = _.camelCase(this.step)
const name = camelCaseName.charAt(0).toUpperCase() + camelCaseName.slice(1)
return () => import(`@/components/ProfileSetup/GMB/${name}`)
}
}
}
</script>
В моем тесте мне просто нужно убедиться, что импортированный компонент отображается. Вот мой тестовый файл:
import { createLocalVue, shallowMount } from '@vue/test-utils'
import SetupFlow from '@/components/ProfileSetup/SetupFlow'
const localVue = createLocalVue()
describe('SetupFlow.vue', () => {
let propsData
let stubs
beforeEach(() => {
propsData = {
type: 'GMB',
step: 'step-example' // this file does not exist, so I need to mock `import`
}
})
it('renders the given step component', async () => {
const wrapper = shallowMount(SetupFlow, { localVue, propsData })
})
})
Это ошибка, которую я получаю при запуске теста:
Любые идеи, как смоделировать import
, чтобы step-example
возвращает макет vue компонента?