'Jest on promises: triggerUncaughtException(err, true /* fromPromise */)
I'm getting this error while running ALL tests (when I the only test directly that load the function involved, there's no error)
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block,
or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason
"Error: Ha ocurrido un error, por favor intente de nuevo más tarde".] {
code: 'ERR_UNHANDLED_REJECTION'
}
The block of code of the function that is generating the error is like this:
async getMonthRequests(rut, month) {
try {
// some code, in the test I'm testing that it fails
} catch (error) {
return Promise.reject('Ha ocurrido un error, por favor intente de nuevo más tarde');
}
}
Any idea?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
