我正在尝试建立一个库存系统,我想添加一个Item,所以我制作了一个代码来查看更新是如何工作的,并且我继续在断言上获得错误。所以我使用IF ELSE语句来比较和记录结果,即使更新结果(state2)与预期(state3)相同,我总是得到NOT EQUAL。
const state1 = ['x','y'];
const state2 = update(state1, {$push: ['z']});
const state3 = ['x', 'y', 'z'];
expect(state2).to.equal(state3);
//log results
if (state2 === state3) {
console.log("EQUAL!!! state2 = " + state2 + ", state3 = " + state3);
} else {
console.log("NOT EQUAL!!! state2 = " + state2 + ", state3 = " + state3);
}
我得到的断言错误是:
AssertionError: expected [ 'x', 'y', 'z' ] to equal [ 'x', 'y', 'z' ]