I ran into a problem when running a component test that has a line inside it:
const route = useRoute()
. I get an error: Cannot read properties of undefined (reading 'path')
. Here is the test:
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)
})
})