我正在使用Testcafe Vue选择器在Vue应用程序上执行e2e测试,但看起来我无法捕获我的任何组件:
1) An error occurred in getVue code:
TypeError: Cannot read property '__vue__' of undefined
这是我创建的样本测试:
import VueSelector from "testcafe-vue-selectors";
import { Selector } from 'testcafe';
fixture `Getting Started`
.page `http://localhost:8081/`;
test('test totalValue format', async t => {
const totalValue = VueSelector("total-value");
await t
.click("#total-value-toggle-format")
.expect(totalValue.getVue(({ props }) => props.formatProperty)).eql(null)
});
我的组件树的结构如下:
Root
|___App
|___Hello
|___TotalValue
然后像这样导入组件:
"total-value": TotalValue,
为什么这不起作用?
编辑:这是我测试组件的页面
<template>
<div class="hello">
<div class="component-wrapper">
<total-value
:value="totalValueValue"
:formatProperty="computedFormatNumber">
</total-value>
</div>
</div>
</template>
<script>
import TotalValue from "../../core/TotalValue";
export default {
name: "hello",
components: {
"total-value": TotalValue,
},
data() {
return {
totalValueValue: 1000000,
formatNumber: true,
formatFunction: Assets.formatNumber,
};
},
computed: {
computedFormatNumber() {
return this.formatNumber ? ["nl", "0,0 a"] : [];
},
},
};
最佳答案
只是后续操作,我们已修复此线程中描述的问题:
Support component loaded via vue-loader
关于javascript - Testcafe Vue选择器无法获取Vue组件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44585727/