Message “Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout”

后端 未结 16 1608
[愿得一人]
[愿得一人] 2020-11-28 02:56

I\'m using Puppeteer and Jest to run some front end tests.

My tests look as follows:

describe("Profile Ta         


        
16条回答
  •  难免孤独
    2020-11-28 03:25

    The timeout you specify here needs to be shorter than the default timeout.

    The default timeout is 5000 and the framework by default is jasmine in case of jest. You can specify the timeout inside the test by adding

    jest.setTimeout(30000);
    

    But this would be specific to the test. Or you can set up the configuration file for the framework.

    Configuring Jest

    // jest.config.js
    module.exports = {
      // setupTestFrameworkScriptFile has been deprecated in
      // favor of setupFilesAfterEnv in jest 24
      setupFilesAfterEnv: ['./jest.setup.js']
    }
    
    // jest.setup.js
    jest.setTimeout(30000)
    

    See also these threads:

    setTimeout per test #5055

    Make jasmine.DEFAULT_TIMEOUT_INTERVAL configurable #652

    P.S.: The misspelling setupFilesAfterEnv (i.e. setupFileAfterEnv) will also throw the same error.

提交回复
热议问题