我正在寻找一种通过Jest设置总时限测试的方法,例如expect(somefunction()).toTake(1000)
。我知道测试的第二个参数是异步函数的超时,但是我专门在测试整个函数(异步和非异步部分)的性能,并针对运行该功能所花费的时间。
答案 0 :(得分:1)
这里的评论可能会帮助您解决jest存储库中的相关问题; https://github.com/facebook/jest/issues/2694#issuecomment-411499373
此外,这是该注释中的代码段。
[
{
"data": "xxx#12#1",
"id": "7_0_0"
},
{
"data": "xxx#12#1",
"id": "8_0_1"
},
{
"data": "xxx#12#1",
"id": "9_1_0"
},
{
"data": "xxx#12#1",
"id": "10_1_1"
},
{
"data": "xxx#12#1",
"id": "11_2_0"
},
{
"data": "xxx#12#1",
"id": "12_2_1"
},
"xxx#12#1",
"7_0_0",
"xxx#12#1",
"8_0_1",
"xxx#12#1",
"9_1_0",
"xxx#12#1",
"10_1_1",
"xxx#12#1",
"11_2_0",
"xxx#12#1",
"12_2_1"
]