I am unit testing some JavaScript with Jasmine and wish to spy on (mock) an element of the DOM that is accessed by a jQuery selector.
My spec is:
it(
You could create your own fake DOM element and then use $('#elementid')[0] as usual
addFakeElementWithId = function (elementId) { var fake = document.createElement("div"); fake.setAttribute("id", elementId); document.body.appendChild(fake); };