vlucas / frisby

Frisby is a REST API testing framework built on Jest that makes testing API endpoints easy, fast, and fun.

Home Page:http://frisbyjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

frisby tests passed but throwing UnhandledPromiseRejectionWarning

shahidv3 opened this issue · comments

commented

hi @H1Gdev @vlucas

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_

@shahidv3

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.