嘿,所以我今天在玩 Jasmine,我写了这个简单的 Person 对象
function Person() {}
Person.prototype.name = "Alex";
Person.prototype.age = 24;
这是我的规格测试
describe("Person", function() {
var someone = new Person();
it('should be equal to other people', function() {
var another = {
name: "Joe",
age: 25,
};
expect(someone).toEqual(another);
});
});
然而它失败了 Expected { } to equal { name : 'Alex', age : 24 } Jasmine 的 toEqual 匹配器不应该适用于对象吗?我在这里错过了什么吗?
谢谢!