1
0
mirror of synced 2025-12-20 02:19:14 -05:00

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:
Peter Bengtsson
2021-12-13 11:20:05 -05:00
committed by GitHub
parent 3e6eb01d57
commit 51e1b14c4e
4 changed files with 21 additions and 3 deletions

View File

@@ -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) {