我已将 Cypress Vue 组件测试运行器添加到现有的 Vue(vite) 应用程序中。但是,当我运行测试时,我收到一个错误,即我的组件中的 $route 未定义。我的组件测试设置是否遗漏了什么?也许关于Vue路由器?
测试设置:
import { mount } from "@cypress/vue";
import ProductListContainer from "./ProductListContainer.vue";
it("renders a message", () => {
mount(ProductListContainer);
...
});
模板:
<template>
//...
<template #pagination>
<nav-pagination
:page-count="meta ? meta.pageCount : 0"
:route-query="$route.query"
/>
</template
</template>
错误:
TypeError
Cannot read property 'query' of undefined
控制台日志行:
....
"route-query": _ctx.$route.query