Sunday 26 April 2020

Destructuring always creates a new instance of a value.

I recently faced an issue in my tests where stubs did not work at all.I am using the got library to make HTTP requests and no matter how I stubbed the HTTP methods, the API calls would always go through no matter what.Turns out the answer to this issue was quite a simple principle that I could not place directly. Destructuring will always create a new instance of a value and will not point to the same value anymore.The functions were destructuring the HTTP function and the test was importing a new instance of the HTTP function that would not get stubbed.I wrote this up on my blog detailing on what was happening and how we tried fixing it temporarilyhttps://blog.eyadkobatte.com/making-sense-of-destructured-imports-for-testing-and-stubs/

Submitted April 26, 2020 at 03:28PM by eyadkobatte

No comments:

Post a Comment