Any best way to run the jasmine HTML reporter with browserify styled code? I also want to be able to run this headless with phantomjs, thus the need for the HTML reporter.
I've created a detailed example project which addresses the jasmine testing (and others) - see https://github.com/amitayd/grunt-browserify-jasmine-node-example. Discussion at my blog post
The approach in this aspect was to create a Browserify bundle for the main source code (where all the modules are exposed), and one for tests which relies on external for the main source code. Then tests can be run both in PhantomJS or a real browser.
I don't think there's a jasmine-browserify
package yet, and it doesn't really match Browserify/NPM's way of doing things (avoid global exports).
For now, I just include /node_modules/jasmine-reporters/ext/jasmine.js
and jasmine-html.js
at the top of my <head>
, and require all my specs in a top-level spec_entry.js
that I then use as the entry point for a Browserify bundle that I put right afterwards in the <head>
. (Note that if the entry point is not top-level, you'll have a bad time due to a long-lasting, gnarly bug in Browserify).
This plays nicely with jasmine-node
as long as you don't assume the presence of a global document
or window
. However, you do have to remember to register your specs in that spec_entry.js
, unless you want to hack Browserify to get it to crawl your directories for .spec.js
files.
I'd be very interested in a more elegant solution, though, that would transparently work with jasmine-node and browserify.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With