Browserify is an awesome tool for managing front-end module dependencies with
require, just like you would in Node. Karma is a killer JS test runner that's
super fast and easy. But put them together and you're entering a world of pain.
This plugin aims to make them play nice.
Under most circumstances, Browserify attempts to give you a single monolithic
bundle of all of your JS files and their dependencies. That's perfect for fast
delivery with minimal requests in a browser environment, but sucks hard if
you're just trying to run your tests (over and over). This plugin hijacks the
Browserify pipeline to produce a single bundle of all dependencies found in
your tests (and their dependencies) which is transferred to the browser under
test only once (unless it changes). A separate, minimal bundle is generated for
each test which, aside from the test code, only contains references to
external dependencies in the main bundle. That way dependencies are updated in
the browser only when necessary (watching for changes is supported) and your
tests remain lightning fast.
karma-browserify
Browserify for Karma
Browserify is an awesome tool for managing front-end module dependencies with
require
, just like you would in Node. Karma is a killer JS test runner that's super fast and easy. But put them together and you're entering a world of pain. This plugin aims to make them play nice.Under most circumstances, Browserify attempts to give you a single monolithic bundle of all of your JS files and their dependencies. That's perfect for fast delivery with minimal requests in a browser environment, but sucks hard if you're just trying to run your tests (over and over). This plugin hijacks the Browserify pipeline to produce a single bundle of all dependencies found in your tests (and their dependencies) which is transferred to the browser under test only once (unless it changes). A separate, minimal bundle is generated for each test which, aside from the test code, only contains references to external dependencies in the main bundle. That way dependencies are updated in the browser only when necessary (watching for changes is supported) and your tests remain lightning fast.
Installation
Install the plugin from npm:
Or from Github:
Add
browserify
to theframeworks
andpreprocessor
keys in your Karma configuration:Options
The plugin may be configured using the
browserify
key in your Karma config:Usage
Just
require
modules from within tests as you normally would in Node:See the example for a simple working setup.