# karma-bro

> A fast browserify integration for Karma that handles large projects with ease

Latest version **0.11.1** (published 2014-11-13) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install karma-bro
pnpm add karma-bro
yarn add karma-bro
bun add karma-bro
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.11.1 |
| Published | 2014-11-13 |
| First published | 2014-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+10 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 315 |
| Maintainers | nikku, bendrucker |
| Keywords | karma-plugin, karma-preprocessor, browserify-tool, browserify |

## Links

- npm: https://www.npmjs.com/package/karma-bro
- Repository: git@github.com:Nikku/karma-bro
- Homepage: https://github.com/Nikku/karma-bro
- Issues: https://github.com/Nikku/karma-bro/issues
- npm.io page: https://npm.io/package/karma-bro

## Dependencies (6)

- [lodash](https://npm.io/package/lodash.md) ~2.4.1
- [watchify](https://npm.io/package/watchify.md) ^2.1.1
- [minimatch](https://npm.io/package/minimatch.md) ^1.0.0
- [browserify](https://npm.io/package/browserify.md) ^6.3.2
- [js-string-escape](https://npm.io/package/js-string-escape.md) ^1.0.0
- [convert-source-map](https://npm.io/package/convert-source-map.md) ~0.3.3

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.11.1 (latest) — 2014-11-13
- 0.11.0 — 2014-11-13
- 0.10.0 — 2014-11-04
- 0.9.0 — 2014-10-27
- 0.8.0 — 2014-09-29
- 0.7.1 — 2014-09-26
- 0.7.0 — 2014-08-31
- 0.6.2 — 2014-07-31
- 0.6.1 — 2014-07-28
- 0.6.0 — 2014-06-30
- 0.5.0 — 2014-06-12
- 0.4.0 — 2014-06-02
- 0.3.0 — 2014-05-24
- 0.2.2 — 2014-05-01
- 0.2.1 — 2014-05-01
- … 2 more at https://npm.io/package/karma-bro/versions

## README

> __This project has renamed to [karma-browserify](https://github.com/Nikku/karma-browserify) as of version `1.0`__.

# karma-bro

[Bro](https://github.com/Nikku/karma-bro) is a fast [browserify](http://browserify.org) integration for [Karma](https://karma-runner.github.io) that handles large projects with ease.


## Installation

Get the plug-in via [npm](https://www.npmjs.org/)

```
npm install --save-dev karma-bro
```


## Usage

Add `browserify` as a framework to 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.


```javascript
module.exports = function(karma) {
  karma.set({

    frameworks: [ 'browserify', 'jasmine', 'or', 'any', 'other', 'framework' ],

    preprocessors: {
      'test/**/*.js': [ 'browserify' ]
    },

    browserify: {
      debug: true,
      transform: [ 'brfs' ]
    }
  });
}
```

Look at the [example directory](https://github.com/Nikku/karma-bro/tree/master/example) for a simple [browserify](http://browserify.org) + [jasmine](http://jasmine.github.io) project that uses this plug-in.


### Browserify Config

Test bundles can be configured through the `browserify` karma configuration property. [Configuration options](https://github.com/substack/node-browserify#var-b--browserifyfiles-or-opts) are passed directly to browserify.

For example to generate source maps for easier debugging, specify:

```javascript
    browserify: {
      debug: true
    }
```

There are three properties that are not passed directly:

* [transform](#transforms)
* [plugin](#plugins)
* [prebundle](#additional-bundle-configuration)

#### Transforms

If you use CoffeeScript, JSX or other tools that need to transform the source file before bundling, specify a [browserify transform](https://github.com/substack/node-browserify#btransformtr-opts) (karma preprocessors are [not supported](https://github.com/Nikku/karma-bro/issues/36)).

```javascript
    browserify: {
      transform: [ 'reactify', 'coffeeify', 'brfs' ]

      // don't forget to register the extensions
      extensions: ['.js', '.jsx', '.coffee']
    }
```

You can also specify options for the transformations:

```javascript
    browserify: {
      transform: [ ['reactify', {'es6': true}], 'coffeeify', 'brfs' ]
    }
```

#### Plugins

The [browserify plugin](https://github.com/substack/node-browserify#bpluginplugin-opts) option supports the same syntax as `transform`.

```javascript
    browserify: {
      plugin: [ 'stringify' ]
    }
```

#### Additional Bundle Configuration

You may perform additional configuration in a function that you pass as the `prebundle` option and that receives the bundle as an argument. This is useful when you need to set up things like [externals](https://github.com/substack/node-browserify#external-requires):

```javascript
    browserify: {
      prebundle: function(bundle) {
        bundle.external('foobar');
      }
    }
```


## How it Works

Bro is a preprocessor for Karma that combines test files and dependencies into a browserified bundle. It relies on [watchify](https://github.com/substack/watchify) to generate the bundle and to keep it updated during `autoWatch=true`.

Before the initial test run Bro builds one browserify bundle for all test cases and dependencies. Once any of the files change, it incrementally updates the bundle. Each file included in karma is required from the file bundle via a stub. Thereby it ensures tests are only executed once per test run.


## Detailed Configuration

The following code snippet shows a Karma configuration file with all Bro related options.

```javascript
module.exports = function(karma) {
  karma.set({

    // include browserify first in used frameworks
    frameworks: [ 'browserify', 'jasmine' ],

    // add all your files here,
    // including non-commonJS files you need to load before your test cases
    files: [
      'some-non-cjs-library.js',
      'test/**/*.js'
    ],

    // add preprocessor to the files that should be
    // processed via browserify
    preprocessors: {
      'test/**/*.js': [ 'browserify' ]
    },

    // see what is going on
    logLevel: 'LOG_DEBUG',

    // use autoWatch=true for quick and easy test re-execution once files change
    autoWatch: true,

    // add additional browserify configuration properties here
    // such as transform and/or debug=true to generate source maps
    browserify: {
      debug: true,
      transform: [ 'brfs' ],
      prebundle: function(bundle) {
        // additional configuration, e.g. externals
        bundle.external('foobar');
      }
    }
  });
};
```


## Related

Credit goes to to [karma-browserify](https://github.com/xdissent/karma-browserify) and [karma-browserifast](https://github.com/cjohansen/karma-browserifast). Bro builds on the lessons learned in these projects and offers improved configurability, speed and/or the ability to handle large projects.



## Maintainers

* [Ben Drucker](https://github.com/bendrucker)
* [Nico Rehwaldt](https://github.com/Nikku)


## License

MIT

---
_Source: https://npm.io/package/karma-bro · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
