Unit testing Jasmine TohavenCalled中Vue的单元测试,使用Vue getter调用
我有一个单元测试代码,当我运行Unit testing Jasmine TohavenCalled中Vue的单元测试,使用Vue getter调用,unit-testing,vue.js,jasmine,Unit Testing,Vue.js,Jasmine,我有一个单元测试代码,当我运行纱线运行测试时,该代码没有通过测试: it(' << description >>', () => { const value = { a: 'A', b: 'B', c: 'C', }; const component = wrapper.vm; component.onChanged([]); expect(onUpdateSpy).toHaveBeenCa
纱线运行测试时,该代码没有通过测试:
it(' << description >>', () => {
const value = {
a: 'A',
b: 'B',
c: 'C',
};
const component = wrapper.vm;
component.onChanged([]);
expect(onUpdateSpy).toHaveBeenCalledWith(value);
});
it('>',()=>{
常量值={
a:‘a’,
b:‘b’,
c:‘c’,
};
const component=wrapper.vm;
组件。一旦更改([]);
期望(onUpdateSpy).已被(值)调用;
});
错误消息是:
Expected spy onUpdate to have been called with
[ Object({ a: 'A', b: 'B', c: 'C' }) ]
but actual calls were [ [ Object({ a: <getter>, b: <getter>, c: <getter> }) ] ].
预期已使用调用spy onUpdate
[对象({a:'a',b:'b',c:'c'})]
但实际调用是[[Object({a:,b:,c:})]。
我猜这是因为参数是被动的,但我别无选择,只能使预期输出不是被动的,以便检查值。然而,我仍然需要根据我给出的输入测试结果。
在这种情况下我该怎么办
多谢各位