[英]How to use Jasmine's toEqual(jasmine.objectContaining) method to compare arrays?
Basically I wanna check corresponding elements of the arrays I partially equal.基本上我想检查我部分相等的数组的相应元素。
Is there anything better than foreach loop
with a nested toEqual(jasmine.objectContaining)
?有什么比foreach loop
更好的嵌套toEqual(jasmine.objectContaining)
吗?
With angularjs and Jasmine 3.3.1, I have been successful with this kind of structure:使用 angularjs 和 Jasmine 3.3.1,我已经成功地使用了这种结构:
it('updates an prop on every object in an array', () => {
const result = service.methodThatUpdates([{ prop: 'orig' }, { prop: 'orig' }]);
expect(result).toEqual([
jasmine.objectContaining({ prop: 'changed' }),
jasmine.objectContaining({ prop: 'changed' })
]);
});
It is simpler than many toEqual
calls.它比许多toEqual
调用简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.