Skip to content

For request failures and timeouts, include the URLs in the errors#1475

Open
giles-v wants to merge 1 commit intoJakeChampion:mainfrom
giles-v:show-urls-in-messages
Open

For request failures and timeouts, include the URLs in the errors#1475
giles-v wants to merge 1 commit intoJakeChampion:mainfrom
giles-v:show-urls-in-messages

Conversation

@giles-v
Copy link

@giles-v giles-v commented Dec 18, 2024

When working with complex Jest tests which mount large component trees, it can be difficult to nail down which request is causing test failures with the current message. Echo the specific method and URL into the Error, so that debugging is easier.

xhr.onerror = function() {
setTimeout(function() {
reject(new TypeError('Network request failed'))
reject(new TypeError('Network request ('+request.method+' '+request.url+') failed'))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These would be neater as string template literals, but since those were not currently in use in the codebase, I opted to match the existing style of plain strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant