【发布时间】:2017-08-03 13:59:57
【问题描述】:
这是我的组件:
<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”)。
【问题讨论】:
标签: javascript vue.js vuejs2 karma-mocha