KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to get better at unit testing my JavaScript. I have the following code: var categoryVal = $('#category').val(); if (categoryVal === '') { doSomething(); } My test runner doesn't have the #category input on the page, so how would I stub/mock out the jQuery selector here? I've looked at both the jasmin and sinon documentation, but can't figure out how to get them to work here, since their stubs operate on objects, which $ is not.
Tags (comma-separated)
Save Edits
Cancel