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

createStubInstance fails with property getters that have deep chains #1036

Closed
mattjhussey opened this issue Apr 27, 2016 · 6 comments
Closed
Milestone

Comments

@mattjhussey
Copy link

mattjhussey commented Apr 27, 2016

We understand you have a problem and are in a hurry, but please provide us with some info to make it much more likely for your issue to be understood, worked on and resolved quickly.

  • Sinon version : I am using github version in my package.json defined: "sinonjs/sinon"
  • Environment : Windows 7 x64
  • Example URL : My project is not online, but the problem I am having is with Cesium https://cesiumjs.org/
  • Other libraries you are using: Loads... Karma, Chai and Cesium are the ones most relevant.

What did you expect to happen?
That a Stub of Cesium's Viewer would be produced and I could work with it.

What actually happens
TypeError: Cannot read property 'defaultDataSource' of undefined
sinon/lib/sinon/util/core/walk.js:23:0
sinon/lib/sinon/util/core/walk.js:18:0
sinon/lib/sinon/util/core/walk.js:29:0
sinon/lib/sinon/util/core/walk.js:44:0
sinon/lib/sinon/stub.js:59:0
sinon/lib/sinon/stub.js:81:0
createStubInstance crashes while walking. It gets to the 'entities' property of Cesium's Viewer and crashes with the error:
It seems to be because the property is defined as:
entities : { get : function() { return this._dataSourceDisplay.defaultDataSource.entities; } }
and this._dataSourceDisplay is undefined.
I think it's because a property is doing a little more than it should, but these things are likely to happen in some people's code and it's a 3rd party library rather than my own code.

How to reproduce

Describe with code how to reproduce the faulty behaviour,
or link to code on JSBin or similar

I've had a go at this. It's not the same version of sinon but I wasn't sure how to get it working. With this version there seems to be no problem. If you let me know how to use the latest sinon like this then I will try it again.
http://jsbin.com/nipukikiqi/edit?html,js,console

See this for an example

@mantoni
Copy link
Member

mantoni commented Jun 3, 2016

#1059 will likely fix this issue. Sorry to keep you waiting.

@delasteve
Copy link

@mantoni Is #1059 going to go in the 1.x branch or just the 2.0.0? If the latter, is it possible to release a sinon@next for 2.0.0 so we can begin using your fix? Currently, trying to use sinon with Angular2 breaks when you try to stub out Router and a couple other objects due to this issue.

@mantoni
Copy link
Member

mantoni commented Jul 6, 2016

@fatso83 Wheren't you planing to cut another sinon@next release?

@fatso83
Copy link
Contributor

fatso83 commented Jul 6, 2016 via email

@delasteve
Copy link

@fatso83 no worries! You guys are doing an awesome job!

@jonnyreeves jonnyreeves added this to the 2.0 milestone Jul 11, 2016
@jonnyreeves
Copy link
Contributor

#1059 was merged into master and sinon@2.0.0-pre.2 was published to NPM. I'm going to resolve this issue, please re-open if you feel there's more work to be done here, please :)

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

5 participants