karma-bro
A fast browserify integration for Karma that handles large CommonJS / browserify projects with ease.
Installation
Get the plug-in via npm:
npm install --save-dev karma-bro
Usage
Add browserify
as the first framework used in your Karma configuration file. For each file that should be processed and bundled by karma, configure the browserify
preprocessor. Optionally use the browserify
config entry to configure how the bundle gets created.
module.exports = function(karma) {
karma.set({
frameworks: [ 'browserify', 'any', 'other', 'framework' ],
preprocessors: {
'test/**/*.js': [ 'browserify' ]
},
browserify: {
debug: true,
transform: [ 'brfs' ]
}
});
}
Look at the example directory for a simple browserify
+ jasmine
project that uses karma-bro
.
Supported Browserify Options
The following browserify configuration options are supported through the browserify: {}
block to tune the way file bundles are created:
- extensions
- builtins
- basedir
- commondir
- resolve
- transform
In addition, specify debug: true
in the options to generate source maps.
Detailed Configuration
The following code snippet shows a Karma configuration file with all karma-bro
related options.
module.exports = function(karma) {
karma.set({
frameworks: [ 'browserify', 'jasmine' ],
files: [
'test/**/*.js'
],
preprocessors: {
'test/**/*.js': [ 'browserify' ]
},
logLevel: 'LOG_DEBUG',
autoWatch: true,
browserify: {
debug: true,
transform: [ 'brfs' ]
}
});
};
Related Projects
Thanks goes to to karma-browserify and karma-browserifast. Both influenced this project by providing prior integrations of browserify into Karma.
Differences
There exist a number of noteworthy differences between karma-bro
and the above mentioned projects:
- It builds only one browserify bundle and keeps that bundle updated incrementally once changes occur
- It makes sure that individual tests are only executed once per test run
- For change detection during
autoWatch=true
it relies solely on watchify - It provides a clean(er) syntax for configuring browserify
License
MIT