1
这里是我的组件:Vue的单元测试 - 的textContent不包含预期propsData
<template>
<div>
{{serviceConfig.name}}
</div>
</template>
<script>
export default {
props: ['serviceConfig']
}
</script>
在我的测试,我设置serviceConfig这样的:
it(`should render serviceConfig`,() => {
const Constructor = Vue.extend(TestMe2);
const comp = new Constructor({
propsData: {
serviceConfig: '{ "name": "Apple" }'
}
}).$mount();
expect(comp.serviceConfig).to.equal('{ "name": "Apple" }'); // successfull
expect(comp.$el.textContent).to.contain('Apple'); // unsuccessfull
});
但是,如果我改变我这样我就可以渲染{{serviceConfig}}而不是serviceConfig.name,它可以工作,但不是我想要的(因为我只是想要名称,即'Apple')。
duh ............ – Infodayne