Challenge: our team is using PhantomJS to run Jasmine tests via karma. All of the rest of our infrastructure, both test and development, makes use of RequireJS to handle dependencies. I’m not well-versed in RequireJS, but it hasn’t been an issue so far, as I’d been extending stuff already built out. Today, I needed to test code that was in a new set of files I’d created. Wasn’t working.
Collecting notes here in terms of what I needed, which also provides clues to the discerning reader of what bit me…. My hope is to revisit this post sometime in the future and amend it as I’m a bit more expert in all of these areas…
– my code needed to be set up as a Require module with a define() block at the top, even though the thing I’m extending isn’t in a require module. (We cheat and stub out our other invocations of the underlying API, so this was a new thought to me, that I needed to set this up as a Require module itself…)
– that module’s function needed to return something. Just having things happen in the function within the define block really doesn’t do it.
– the new module needed to be made visible as a name in my test-main.js
– the new file needed to be made visible to the configuration to Phantom
Takeaway: Lots of places to put things to make things “just work”.