Api Get Timeout-在jest.setTimeout指定的5000ms超时内未调用异步回调

Api Get Timeout-在jest.setTimeout指定的5000ms超时内未调用异步回调,api,testing,jestjs,web-api-testing,Api,Testing,Jestjs,Web Api Testing,我对jest的api测试有问题 当前的行为是什么? Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout. at ../../../../Users/chhoeurng.sakona/AppData/Roaming/npm/node_modules/jest-cli/node_modules/jest-jasmine2/build/queue_r

我对jest的api测试有问题

当前的行为是什么?

 Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
      at ../../../../Users/chhoeurng.sakona/AppData/Roaming/npm/node_modules/jest-cli/node_modules/jest-jasmine2/build/queue_runner.js:68:21
我当前的代码

it ('GET should return a status of 200 OK', function (done) {
        frisby
            .get('url-api')
            .expect('status', 200)
            .done(done);
    });
当前的行为是什么?
它应该工作正常,没有错误。

请提供准确的Jest配置
我没有配置

在项目目录中运行
npx envinfo--preset jest
,然后粘贴 此处的结果

 System:
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
  Binaries:
    Node: 8.11.1
    Yarn: Not Found
    npm: 5.6.0
   jest v22.4.3

使用承诺时,您需要返回承诺或使用异步函数:

it ('GET should return a status of 200 OK', async() => {
        await frisby
            .get('url-api')
            .expect('status', 200)

    });


请看一下

嗨,安德烈亚斯,我在使用你的第二个代码时仍然遇到了这个错误。第一段代码不正确。请你帮个忙。现在我试着用这个改变这一行,然后它就工作了。
it('GET应该返回200 OK',async(done)=>{
你能帮我一下吗,我不知道我的代码哪里错了,它仍然会超时。
const frisby=require('frisby'));const-Joi=frisby.Joi;//frisby导出Joi是为了方便进行类型断言,它('Should sakona返回状态200',function(done){返回frisby.get('url-api')。expect('status',200)。expect('json','status','3')。expect('jsonTypes','merchants*',{//Assert*each*对象在'items'数组'uid':Joi.number().required(),'category':Joi.string().required(),}).done(done)
最好的方法是不要使用
done
毕竟,因为在使用我的答案中描述的异步函数时不需要它。我将更新代码以使其更清晰谢谢
it ('GET should return a status of 200 OK', function () {
        return frisby
            .get('url-api')
            .expect('status', 200)

    });