I am using sinon v4.1.2. According to the documentation (http://sinonjs.org/releases/v4.1.2/sandbox/), I should be able to set a property using the following:
sandbox.stub(myObject, 'hello').value('Sinon');
However, I am getting the error:
Property 'value' does not exist on type 'SinonStub'
What is the real way to do this? I looked through all the available functions, and tried returnValue
, but that isn't a valid function either.
The following was working on an older version of sinon:
sandbox.stub(myObject, 'hello', 'Sinon');
This works for me with Sinon.JS v4.1.2:
myObject = {hello: 'hello'}
sandbox = sinon.createSandbox()
sandbox.stub(myObject, 'hello').value('Sinon')
myObject.hello // "Sinon"
sandbox.restore()
myObject.hello // "hello"