Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unable to access response headers when using axios 1.x with jest #5017 #5036

Merged
merged 1 commit into from Oct 6, 2022

Conversation

risa
Copy link
Contributor

@risa risa commented Oct 6, 2022

When axios 1.0.0 runs under jest, it fails to set headers on the response object properly.

For a detailed description please see here: #5017

The problem in the plainObject check function, where

prototype === null || prototype === Object.prototype;

Is false for response.headers under jest, as jest seems to modify prototype of objects.

The fix is inspired by the is plain module https://github.com/sindresorhus/is-plain-obj, mainly their checking logic:

https://github.com/sindresorhus/is-plain-obj/blob/68e8cc77bb1bbd0bf7d629d3574b6ca70289b2cc/index.js#L7

Edit: I do now know how to write a test for this, as it manifests only under a different test framework than the project uses.

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.

None yet

2 participants