【发布时间】:2022-08-18 21:53:06
【问题描述】:
在使用空对象测试具有属性的对象时,我的测试通行证:
it(\'Should not match object with properties with empty object\', () => {
const testingObject = { a: 1, b: 2 };
expect(testingObject).toMatchObject({});
});
现在,当与具有不属于testingObject 我的测试的另一个属性的对象进行比较时通行证,这是预期的:
it(\'Should not match object with property that does not exist in the original object\', () => {
const testingObject = { a: 1, b: 2 };
expect(testingObject).not.toMatchObject({ c: 3 });
});
这种行为很奇怪,因为我预计这两个测试都会失败。