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

#692 'Feature: getters & setters' does not work with sandbox #1005

Closed
i2infinity opened this issue Mar 10, 2016 · 1 comment
Closed

#692 'Feature: getters & setters' does not work with sandbox #1005

i2infinity opened this issue Mar 10, 2016 · 1 comment

Comments

@i2infinity
Copy link

Looks like #692 does not work with sandbox. I am using sinon@1.17.3 from node

The following code throws error TypeError: Cannot set property foo of #<Object> which has only a getter at Object.stub while stubbing the getter

        var o = {
            get foo() { return 'foo' }
        };
        var mySandbox = sinon.sandbox.create();
        mySandbox.stub(o, 'foo', { get: function () { return 'foo stubbed via sandbox' }});

This works as expected

        var o = {
            get foo() { return 'foo' }
        };

        sinon.stub(o, 'foo', { get: function () { return 'foo stubbed' }});
        console.log(o.foo); // foo stubbed
@i2infinity
Copy link
Author

Duplicate of #781

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

No branches or pull requests

1 participant