set jest timeout code example
Example 1: jest timeout
beforeEach(function () {
jest.setTimeout(2000) // ms
});
Example 2: how to increase jest timeout
// 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)