jest.setTimeout.Error: Timeout code example
Example 1: jest timeout
beforeEach(function () {
jest.setTimeout(2000) // ms
});
Example 2: jest Async callback was not invoked within the 5000ms timeout specified by 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)
Example 3: jest timeout
jest.advanceTimersByTime(msToRun)