Using the jQuery widget factory, i want to test internally that methods get called. How can I expose those methods to spy on them?
$.widget 'foo',
_init: ->
@_bar()
_bar ->
barSpy = sinon.spy WidgetPluginObject, '_bar'
$('#foo').foo()
expect(barSpy).to.be.called.once
I am looking to reference the widget plugin object (represented here by WidgetPluginObject
so I can spy on it's methods.
UPDATE
This is for the purposes of unit testing using mocha/chai; not for any sort of debugging.
I think the term inspect or debug would be more appropriate than spy.
Anyways, you can debug any source code using firebug for firefox or the inspector for Chrome (my favorite).
In the image below if you click on the small arrow next to the title it will expand a menu where you can navigate the document structure to find the javascript. On the right side of the inspector are the debug tools.
To pull up the inspector in Chrome hit F12 or you can right click anywhere on the page and choose inspect element.