frisby tests passed but throwing UnhandledPromiseRejectionWarning
shahidv3 opened this issue · comments
im running my tests using frisby v2.x , the tests are passing however i'm seeing UnhandledPromiseRejectionWarning . can you please help. thanks
_Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with --detectOpenHandles
to troubleshoot this issue.
● Cannot log after tests are done. Did you forget to wait for something async in your test?
Attempted to log "
FAILURE Status: 200
JSON: {
"responseTimeStamp": 1xxxxx,
"statusCode": "OK"
}".
at CustomConsole.log (node_modules/jest-util/build/CustomConsole.js:156:10)
at FrisbySpec.inspectLog (node_modules/frisby/src/frisby/spec.js:319:17)
at FrisbySpec._inspectOnFailure (node_modules/frisby/src/frisby/spec.js:328:16)
at e (node_modules/frisby/src/frisby/spec.js:388:16)
at _fetch._fetch.then.response (node_modules/frisby/src/frisby/spec.js:233:34)
(node:10933) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'validate' of undefined_
It is similar to this issue from UnhandledPromiseRejectionWarning
.
First, try to set a enough time not to timeout.
You also need to make sure you are using return frisby.get(...)
inside your tests. Returning a promise inside your it
block will make Jest know there is a promise to wait on and it will handle the failure condition.