Got Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout

纵然是瞬间 提交于 2019-12-24 01:15:36

问题


I have problem with api-testing with jest

What is the current behavior?

 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

My current code

it ('GET should return a status of 200 OK', function (done) {
        frisby
            .get('url-api')
            .expect('status', 200)
            .done(done);
    });

What is the current behavior? It should work normally and no error.

Please provide your exact Jest configuration I do not have configuration

Run npx envinfo --preset jest in your project directory and paste the results here

 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

回答1:


You need to return a promise or use an async function when woking with promises:

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

    });

or

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

    });

Also have a look at the docs



来源:https://stackoverflow.com/questions/49725389/got-timeout-async-callback-was-not-invoked-within-the-5000ms-timeout-specified

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!