improve test debugging and loading of cached redirects json file (#23584)
* improve test debugging and loading of cached redirects json file * exception for testing 500 page itself
This commit is contained in:
@@ -27,6 +27,16 @@ async function logException(error, req) {
|
||||
}
|
||||
|
||||
export default async function handleError(error, req, res, next) {
|
||||
// When you run tests that use things doing get() requests in
|
||||
// our supertest handler, if something goes wrong anywhere in the app
|
||||
// and its middlewares, you get a 500 but the error is never displayed
|
||||
// anywhere. So this is why we log it additionally.
|
||||
// Note, not using console.error() because it's arguably handled.
|
||||
// Some tests might actually expect a 500 error.
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
console.warn('An error occurrred in some middleware handler', error)
|
||||
}
|
||||
|
||||
try {
|
||||
// If the headers have already been sent or the request was aborted...
|
||||
if (res.headersSent || req.aborted) {
|
||||
|
||||
Reference in New Issue
Block a user