Closed tal-rofe closed 2 years ago
Thanks for taking the time to create this issue
Trying to debug a usage issue inside a project one does not have access to is very hard, and so I would suggest you do what we recommend: try to create a minimal reproducible testcase. That saves everyone a lot of time.
If you want to have a look at what that could look like, here is a number of examples:
Making it as easy as git clone foo/issue-323; npm i; npm t;
makes it a lot more likely that you will get some help. Put in the effort and others will too! 🙌
We are trying to keep the GitHub issues list tidy and focused on bugs and feature discussions. This ticket looks like a usage question; please post it to StackOverflow and tag it with sinon
, so the bigger community can help answer your questions.
If you feel that your topic is an issue with Sinon, please open a new ticket and follow the guidelines for reporting an issue.
Describe the bug I try to stub the
fs-extra/outputJson
function, but it fails. My src code is a bit non-trivial. I have an abstract class, and then I try to test a class which extends this abstract class. My abstract class uses theoutputJson
function. I suspect that this use case leads to the issue.To Reproduce You basically need to have an abstract class and then create an another class which extends the abstract one (in 2 different files to ensure reproduction). Then, implement a usage of the
outputJson
function in the abstract class, then test this function by creating instance of the extending class and use the abstract class` function.Expected behavior
outputJson
should be stubbedContext (please complete the following information):
14.0.0
I have the following abstract class which uses the "fs-extra" library:
This is only snippet as I don't find the rest of the class relevant.
Then I have the following class:
And then I try to test the last class:
But for some reason sinon does not stub
fs-extra
, the functionoutputJson
. Why is that? I suspect thefs-extra/outputJson
is not stubbed because of any context issues? My first test fails because the function wasn't stubbed