Dro*_*ont 5 vue-router vuejs3 vue-testing-library
我在运行其中包含一行的组件测试时遇到了问题:
const route = useRoute()。我收到错误:Cannot read properties of undefined (reading 'path')。这是测试:
describe('Tariff card', () => {
const options = {
props: {
name: 'test',
tariffId: 2,
price: 3990,
maxCompanies: 1,
maxCampaigns: 5,
tariffNum: 2,
isFree: false,
duration: 30,
},
global: {
plugins: [createTestingPinia()],
},
}
it('render tariff card', async () => {
jest.mock('vue-router', () => ({
useRoute: jest.fn(() => ({ path: '/' }))
}))
render(TariffCard, options)
})
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
736 次 |
| 最近记录: |