【发布时间】:2022-02-08 10:46:09
【问题描述】:
我的代码中有这部分,我想测试,但是当我运行测试时 route.params 听起来像是错误的:
onMounted(async () => {
try {
const { tokenId } = route.params
我以前是从 url 获取 id 的,但现在要测试一下
我收到此错误 错误类型错误:无法读取未定义的属性“参数”
这是我的测试:
beforeEach(() => {
wrapper = shallowMount(App, {
mocks: {
route: {
params: {
id: 'id'
}
}
},
global: {
plugins: [store],
},
computed: { notFound: () => {} },
})
})
【问题讨论】:
-
路由或 $route ?
-
@jeremycastelli 是路线
标签: vue.js unit-testing jestjs