Advanced Sinon.js tips: How to stub more complex objects (like DOM elements)
Sinon.js quick tip: How to stub/mock complex objects, such as DOM objects | CodeUtopia
Several of my readers have emailed me, asking about how to deal with more complex stubbing situations when using Sinon.js. In this article, we'll look at how to stub objects which are deeply nested, and when functions have more complex return values and they interact with other objects.
3 plus ones
Shared publicly•View activity
- Prateek JadhwaniModeratorHeyi was wondering if you could use Sinon to mock Shadow DOMs.May 23, 2016
- Sure - if you have an object with some function in it, you can stub it :) You can for example stub out `el.createShadowRoot` in a similar way as shown in the article I linkedMay 23, 2016
- Prateek JadhwaniModeratorI see. I totally need to see how it works with Webcomponents that use Shadow DOMs.
ThanksMay 23, 2016
Add a comment...