• Stars
    star
    321
  • Rank 130,436 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fast Browserify integration for Karma that handles large projects with ease

karma-browserify

CI

karma-browserify is a fast Browserify integration for Karma that handles large projects with ease.

Installation

Get the plug-in via npm.

You will also need to install browserify and watchify (for auto-watch only) with it.

npm install --save-dev karma-browserify browserify watchify

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.

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

    frameworks: [ 'browserify', 'jasmine', 'or', 'any', 'other', 'framework' ],
    files: ['test/**/*.js'],
    preprocessors: {
      'test/**/*.js': [ 'browserify' ]
    },

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

Look at the example directory for a simple browserify + jasmine project that uses this plug-in.

Browserify Config

Test bundles can be configured through the browserify Karma configuration property. Configuration options are passed directly to browserify.

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

    browserify: {
      debug: true
    }

There are three properties that are not passed directly:

Transforms

If you use CoffeeScript, JSX or other tools that need to transform the source file before bundling, specify a browserify transform (Karma preprocessors are not supported).

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

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

You can also specify options for the transformations:

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

Plugins

The browserify plugin option supports the same syntax as transform.

    browserify: {
      plugin: [ 'stringify' ]
    }

Additional Bundle Configuration

You may perform additional configuration in a function passed as the configure option and that receives the browserify instance as an argument. A custom prebundle event is emitted on the bundle right before a bundling operation takes place. This is useful when setting up things like externals:

    browserify: {
      configure: function(bundle) {
        bundle.on('prebundle', function() {
          bundle.external('foobar');
        });
      }
    }

You'll also need to use the 'prebundle' event for full control over the order of transforms and plugins:

    browserify: {
      configure: function(bundle) {
        bundle.once('prebundle', function() {
          bundle.transform('babelify').plugin('proxyquireify/plugin');
        });
      }
    }

Note that transforms must only be added once.

Watchify Config

You can configure the underlying watchify instance via config.watchify. This is helpful if you need to fine tune the change detection used during autoWatch=true.

    watchify: {
      poll: true
    }

How it Works

This project is a preprocessor for Karma that combines test files and dependencies into a browserified bundle. It relies on watchify to generate the bundle and to keep it updated during autoWatch=true.

Before the initial test run we build 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 browserify-related options.

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' ],
      configure: function(bundle) {
        bundle.on('prebundle', function() {
          bundle.external('foobar');
        });
      }
    }
  });
};

Related

Credit goes to to the original karma-browserify and karma-browserifast. This library builds on the lessons learned in these projects and offers improved configurability, speed and/or the ability to handle large projects.

Maintainers

License

MIT

More Repositories

1

jquery-bootstrap-scripting

A number of jQuery plugins to ease scripting of bootstrap featured pages.
JavaScript
279
star
2

works-on-my-machine

Continuous integration done right.
261
star
3

wuffle

A multi-repository / multi-organization task board for GitHub issues.
JavaScript
117
star
4

didi

Dependency Injection for JavaScript
JavaScript
87
star
5

camunda-worker-node

Implement your external task workers for Camunda in NodeJS.
JavaScript
51
star
6

node-xsd-schema-validator

A schema (XSD) validator for NodeJS
JavaScript
50
star
7

requirejs-angular-define

A friendly integration of AngularJS into RequireJS powered applications
JavaScript
48
star
8

jquery-tagit

JQuery plugin for auto completion of tags
JavaScript
44
star
9

feelin

A DMN FEEL parser and interpreter written in JavaScript
JavaScript
37
star
10

pfwr

Turns your Markdown file into a beautiful HTML slide deck. Batteries included.
HTML
26
star
11

eslint-plugin-license-header

Rules to validate the presence of license headers in source files.
JavaScript
26
star
12

feel-playground

An interactive playground to try out and learn the DMN FEEL language.
JavaScript
25
star
13

hugo-cli

Run hugo (the static site generator) painlessly from Node
JavaScript
25
star
14

bpmn-js-cli-modeling-dsl

A modeling DSL for bpmn-js
JavaScript
23
star
15

merge-me

A GitHub app that merges your pull requests once all required checks pass.
JavaScript
22
star
16

jquery-controls

Registration of ajax handlers to bind to certain elements of a page
JavaScript
22
star
17

angular-data-depend

A toolkit for implementing complex, data heavy AngularJS applications
JavaScript
19
star
18

nashorn-async

Simple async support for Nashorn (the Java 8 JavaScript Engine)
JavaScript
18
star
19

camunda-playground

Try out and explore Camunda in minutes, not hours.
JavaScript
16
star
20

selection-ranges

Manipulate selection ranges on contenteditable elements.
JavaScript
15
star
21

run-camunda

Download, spin up and shutdown Camunda painlessly from Node.
JavaScript
14
star
22

lezer-feel

Lezer grammar definition for the DMN 1.3 FEEL language
JavaScript
11
star
23

skaat

A Skat game loop
JavaScript
10
star
24

camunda-modeler-plugins-talk-2019

JavaScript
10
star
25

silent-disco

A web-based, collaborative disco
JavaScript
10
star
26

markmark

Markdown language tooling, exposed as a language server
JavaScript
8
star
27

amvn

Maven with change detection and automatic rebuild.
JavaScript
8
star
28

kartoffeldruck

A all-in-one, opinionated, swiss army knife, hackable static site generator.
JavaScript
6
star
29

bpmn-js-debug-overlay

Stepping controls for your BPMN 2.0 processes
JavaScript
6
star
30

camunda-worker-monitor

An external task / worker monitor for Camunda
JavaScript
5
star
31

lang-feel

DMN FEEL language definition for CodeMirror 6
TypeScript
5
star
32

roll-your-own-bpmn-editor

Material for my talk "How to (not) roll your own BPMN editor", given at CamundaCon LIVE 2020.
JavaScript
5
star
33

bpmn-js-copy-paste-example

An example how to copy and paste between multiple instances of bpmn-js
JavaScript
5
star
34

svelte-slot-fill

Slot/Fill for Svelte Apps
JavaScript
4
star
35

bpmn-js-extension-demo

A demo application built around the bpmn-js modeler.
JavaScript
4
star
36

bpmnlint-pack-config

Pack bpmnlint configuration into a browser consumable bundle
JavaScript
4
star
37

image-gallery

A simple to use image gallery
JavaScript
4
star
38

bpmnlint-loader

Consume bpmnlint config files with webpack
JavaScript
3
star
39

action_annotation

Allows to write human readable behavioural descriptions of controller actions which can be accessed inside a rails-app at runtime
Ruby
3
star
40

lordsandknights.automate.js

In-browser automation for Lords and Knights
3
star
41

types-without-typescript

A talk on types without TypeScript
HTML
3
star
42

annotation_security

AnnotationSecurity is a rails plugin which provides a security layer for rails applications. Security policies are set up based on actions and resources and not, as common, based on url patterns.
Ruby
3
star
43

file-drops

A simple in-browser file drop utility.
JavaScript
2
star
44

skaat-app

A simple Skat application
Svelte
2
star
45

bio-dts

Generate type definitions from JavaScript
JavaScript
2
star
46

simple-dialog

A simple dialog component for the browser
HTML
2
star
47

karma-debug-launcher

Launches your favorite browser with your tests in DEBUG view.
JavaScript
2
star
48

2021-token-simulation

Making of token simulation: Understanding bpmn-js extensibility one token at a time
HTML
2
star
49

nixis-commons

Some handy helper libraries for lightweight java web development
Java
2
star
50

create-bpmnlint-plugin

The bpmnlint plug-in scaffolding utility.
JavaScript
2
star
51

kickr.io

A social kicker app. Built with express.js, MongoDB and AngularJS
JavaScript
1
star
52

order-demo-camundacon-2019

JavaScript
1
star
53

skaat-deck

A Skat deck
JavaScript
1
star
54

cockpit-sample-plugin

A sample plugin for camunda cockpit
Java
1
star
55

.github

1
star
56

mons

Stay sane with your multi screen configuration.
JavaScript
1
star
57

wuffle-sync

A friendly bot that synchronizes your Wuffle board
1
star
58

wiredeps

Wire snapshot dependencies during continuous integration builds
JavaScript
1
star
59

kellergucker

A stock value tracker application
Java
1
star
60

lezer-el

Lezer-based EL grammar
JavaScript
1
star
61

camunda-deploy

Deploy to Camunda from the command-line.
JavaScript
1
star
62

split-require-jsx-text

JavaScript
1
star
63

play-2.1.1-testing-samples

Samples for Testing Play 2.1.x applications. Result of Play user group talk in Berlin, 2013-04-15.
Scala
1
star