I am looking for an example for the most trivial sinon use case: mock an entire Object / Array without methods, static properties only, with another one.
I cannot seem to find how to achieve this using sinon. Pseudo code explanation:
sinon.mock(originalObj, myObj);
// do tests using originalObj = myObj...
sinon.restore(originalObj);
Motivation: while this can be achieved easily with a swap variable, things become somewhat ugly if you have to mock several objects and the mock and restore are in different scopes - then you start using a swap array residing in a parent scope.
just use sinon.stub(myObj) and you will get an object where each property is a stub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With