{"schemaVersion":"1.0","canonicalUrl":"https://automationtester.in/failures/unhandled-promise-rejection","slug":"unhandled-promise-rejection","title":"Unhandled promise rejection in tests","signature":"UnhandledPromiseRejection","frameworks":["Jest","Playwright","CI"],"classification":"flaky","summary":"An asynchronous operation rejected without a handler attached in the test or application lifecycle.","causes":[{"title":"A promise was started without awaiting it","explanation":"The rejection escapes after the test moves on.","diagnostic":"Trace every created promise in the failing path and find the missing await or return.","fix":"Await the operation and assert its success or rejection explicitly."},{"title":"Cleanup rejects after teardown","explanation":"A closed page, socket, or server can cause late asynchronous failures.","diagnostic":"Inspect teardown ordering and open handles.","fix":"Stop producers before closing their dependencies and await cleanup."},{"title":"An event handler throws asynchronously","explanation":"Framework callbacks can reject outside the test's main promise chain.","diagnostic":"Capture application errors and identify the originating event.","fix":"Handle the error in the application and expose an observable failure state."}],"prevention":["Fail on unhandled rejections.","Await cleanup.","Keep asynchronous ownership explicit."],"related":["jest-cannot-log-after-tests","assertion-expected-received-mismatch"],"references":[{"label":"Node.js unhandled rejections","url":"https://nodejs.org/api/process.html#event-unhandledrejection"}]}