我在我的测试组中有两个测试。其中一个测试使用it
,另一个使用test
。它们似乎非常相似。它们之间有什么区别?
describe('updateAll', () => {
it('no force', () => {
return updateAll(TableName, ["fileName"], {compandId: "test"})
.then(updatedItems => {
let undefinedCount = 0;
for (let item of updatedItems) {
undefinedCount += item === undefined ? 1 : 0;
}
// console.log("result", result);
expect(undefinedCount).toBe(updatedItems.length);
})
});
test('force update', () => {
return updateAll(TableName, ["fileName"], {compandId: "test"}, true)
.then(updatedItems => {
let undefinedCount = 0;
for (let item of updatedItems) {
undefinedCount += item === undefined ? 1 : 0;
}
// console.log("result", result);
expect(undefinedCount).toBe(0);
})
});
});
更新 - 2022年11月:
根据Jest官方API,似乎test
和it
可以互换使用。正如@gwildu在这里所描述的那样,为了更好的可读性,您应该选择其中之一。