Jest 中的“it"和“test"有什么区别? [英] What is the difference between 'it' and 'test' in Jest?
本文介绍了Jest 中的“it"和“test"有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的测试组中有两个测试.一个测试使用it
,另一个测试使用test
.他们两个的工作方式似乎非常相似.它们有什么区别?
I have two tests in my test group. One of the tests use it
and the other one uses test
. Both of them seem to be working very similarly. What is the difference between them?
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);
})
});
});
似乎test
在Jest的官方API中,但 it
不是.
推荐答案
Jest docs 状态 it
是 test
.因此,从功能的角度来看,它们完全相同.它们的存在都是为了能够从您的测试中生成可读的英语句子.
The Jest docs state it
is an alias of test
. So they are exactly the same from a functional point of view. They exist both to enable to make a readable English sentence from your test.
这篇关于Jest 中的“it"和“test"有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文