I'm working on some
typical mix of RequireJS, jQuery, and Backbone. I ran into an annoying
problem that I hadn't anticipated: loading jQuery via RequireJS in node
isn't exactly straightforward. When I include jQuery in the list of my
module's dependencies and run
make mocha I get this error:
module "jquery" failed with error: TypeError: Cannot call method 'createElement' of undefined
So, this is one of the quirks I should've known I'd run into when I
decided to test our front-end code in node.js instead of in a web
browser. However, I may still be able to continue down this track.
I could figure out why jQuery isn't being loaded here. Maybe it's
some stupid thing I haven't thought of yet, or maybe it's possible
to set up the requirejs config in
behave correctly when loading jQuery.
If I can't figure out how to include jQuery without a browser's DOM, I could try setting up a jsdom instance in the test runner. Really I just don't want to complicate things too much since the test runner is working alright now, and I don't want it to become fragile or hard to understand.