What is the current behavior?
I am getting Timeout - Async callback was not invoked within the 500000ms timeout specified by jest.setTimeout.
Please provide your exact Jest configuration
My testing is currently running inside docker container.
test
This is not an actionable issue report. Please send a better description of what you want to achieve and provide a repro.
@thymikee I am facing a similar error message when running a Jest test: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
My test looks like this:
describe('invalid nonces', () => {
let msg = 'blah blah blah'
it(`Should have error message ${msg}`, async (done) => {
let errors = getErrors(exampleResult)
console.log("errors: " + JSON.stringify(errors, null, 2))
let filteredErrors = errors.filter(err => err.message == msg)
console.log('filteredErrors: ' + JSON.stringify(filteredErrors, null, 2))
expect(errors.length).toBeGreaterThan(0)
expect(filteredErrors.length).toEqual(1)
done()
}, 10000)
})
My assumption is the Async callback being referred to in the error must be something different from the done callback variable I'm passing to this test. How could I find out what the Async callback _is_ referring to?
I figured it out. Had to tweak the test to look like this:
describe('invalid nonces', () => {
let msg = 'blah blah blah'
it(`Should have error message ${msg}`, async () => {
let errors = getErrors(exampleResult)
console.log("errors: " + JSON.stringify(errors, null, 2))
let filteredErrors = errors.filter(err => err.message == msg)
console.log('filteredErrors: ' + JSON.stringify(filteredErrors, null, 2))
expect(errors.length).toBeGreaterThan(0)
return expect(filteredErrors.length).toEqual(1)
}, 10000)
})
I figured it out. Had to tweak the test to look like this:
describe('invalid nonces', () => { let msg = 'blah blah blah' it(`Should have error message ${msg}`, async () => { let errors = getErrors(exampleResult) console.log("errors: " + JSON.stringify(errors, null, 2)) let filteredErrors = errors.filter(err => err.message == msg) console.log('filteredErrors: ' + JSON.stringify(filteredErrors, null, 2)) expect(errors.length).toBeGreaterThan(0) return expect(filteredErrors.length).toEqual(1) }, 10000) })
I don't think this will work for multiple tests. When you have code that runs asynchronously, Jest needs to know when the code it is testing has completed, before it can move on to another test. The way to handle this is via done callback. Jest will wait until the done callback is called before finishing the test.
@ashleshsortee async functions return a Promise, which is how Jest know when the test is complete
Most helpful comment
This is not an actionable issue report. Please send a better description of what you want to achieve and provide a repro.