ES6 + browserify + babel + gulp + jasmine
Published by Carlos Blé on 14/09/2015
As an example, I installed karma via npm the latest version. But when running gulp from the command line it stopped working with no error message at all, just a line break and back to the prompt. I commented all the lines in the gulpfile.js and then uncommented lines one by one executing gulp each time to discover that
require('karma') was the reason. So I got into the *node repl and type this myself:
var k = require(‘karma’)
The result was the same, the node repl exited silently getting me back to the command line prompt. I couldn’t find a single way to catch the error although I tried try-catch, signal capturing, domains… and none of that worked. Then I started downgrading the version of the karma package until it worked for me. Version 0.13.3 works but 0.13.4 doesn’t. It must be a very specific problem on my machine but I couldn’t find any other solution. Eventually we are not using karma for now, we are using jasmine stand alone version and mocha.
This is the simplest gulpfile I was able to get working:
The generated package is all.js which I include in the html page. The application’s entry point is on main.js with exposes a function called startApp.
App starts up at the bottom of the html page:
In order to run the tests the most simple choice was Jasmine stand alone, including the generated specs.js file in the SpecRunner.html page. As the tests include the production code, the generated file specs.js already include all the production code.
The next step was to include watchify in order to rebundle everytime a file is saved.
This post was written on September 14th 2015, if you try to use any of the snippets posted a few months later they probably won’t work for you. These are the versions used:
Originally published in Carlos Blé's blog.