本文介绍了在量角器中声明数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在进行E2E测试,我的目标是比较两个阵列.我将这些数组设置为相同.问题是量角器认为它们不相同.
I am working on E2E tests and my goal is to compare two arrays. I set these arrays so that they are identical. The problem is that Protractor doesn't think they are same.
我的代码:
控制台输出:
如何正确比较它们?
推荐答案
这实际上取决于您如何做出期望. toBe()
将确保两个数组都是同一对象.相反,您需要比较值,使用toEqual()
:
This actually goes down to how are you making the expectation. toBe()
would make sure both arrays are the same object. Instead, you need to compare values, use toEqual()
:
expect(arrPuv).toEqual(arrNov);
另请参阅:
这篇关于在量角器中声明数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!