{"id":13811601,"url":"https://github.com/nikku/karma-browserify","last_synced_at":"2025-05-15T18:06:01.423Z","repository":{"id":16540884,"uuid":"19294390","full_name":"nikku/karma-browserify","owner":"nikku","description":"A fast Browserify integration for Karma that handles large projects with ease","archived":false,"fork":false,"pushed_at":"2021-09-15T12:32:27.000Z","size":701,"stargazers_count":319,"open_issues_count":0,"forks_count":49,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-07T23:27:41.824Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikku.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-29T23:10:58.000Z","updated_at":"2025-03-04T10:48:36.000Z","dependencies_parsed_at":"2022-09-11T10:41:51.023Z","dependency_job_id":null,"html_url":"https://github.com/nikku/karma-browserify","commit_stats":null,"previous_names":["nikku/karma-bro"],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikku%2Fkarma-browserify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikku%2Fkarma-browserify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikku%2Fkarma-browserify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikku%2Fkarma-browserify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikku","download_url":"https://codeload.github.com/nikku/karma-browserify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394719,"owners_count":22063984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T04:00:24.515Z","updated_at":"2025-05-15T18:06:01.375Z","avatar_url":"https://github.com/nikku.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# karma-browserify\n\n[![CI](https://github.com/nikku/karma-browserify/actions/workflows/CI.yml/badge.svg)](https://github.com/nikku/karma-browserify/actions/workflows/CI.yml)\n\n[karma-browserify](https://github.com/nikku/karma-browserify) is a fast [Browserify](http://browserify.org) integration for [Karma](https://karma-runner.github.io) that handles large projects with ease.\n\n\n## Installation\n\nGet the plug-in via [npm](https://www.npmjs.org/).\n\nYou will also need to install [browserify](https://www.npmjs.com/package/browserify) and [watchify](https://www.npmjs.com/package/watchify) (for auto-watch only) with it.\n\n```\nnpm install --save-dev karma-browserify browserify watchify\n```\n\n\n## Usage\n\nAdd `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.\n\n\n```javascript\nmodule.exports = function(karma) {\n  karma.set({\n\n    frameworks: [ 'browserify', 'jasmine', 'or', 'any', 'other', 'framework' ],\n    files: ['test/**/*.js'],\n    preprocessors: {\n      'test/**/*.js': [ 'browserify' ]\n    },\n\n    browserify: {\n      debug: true,\n      transform: [ 'brfs' ]\n    }\n  });\n}\n```\n\nLook at the [example directory](https://github.com/nikku/karma-browserify/tree/master/example) for a simple [browserify](http://browserify.org) + [jasmine](http://jasmine.github.io) project that uses this plug-in.\n\n\n### Browserify Config\n\nTest 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.\n\nFor example to generate source maps for easier debugging, specify:\n\n```javascript\n    browserify: {\n      debug: true\n    }\n```\n\nThere are three properties that are not passed directly:\n\n* [transform](#transforms)\n* [plugin](#plugins)\n* [configure](#additional-bundle-configuration)\n* bundleDelay\n\n\n#### Transforms\n\nIf 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-browserify/issues/36)).\n\n```javascript\n    browserify: {\n      transform: [ 'reactify', 'coffeeify', 'brfs' ]\n\n      // don't forget to register the extensions\n      extensions: ['.js', '.jsx', '.coffee']\n    }\n```\n\nYou can also specify options for the transformations:\n\n```javascript\n    browserify: {\n      transform: [ ['reactify', {'es6': true}], 'coffeeify', 'brfs' ]\n    }\n```\n\n#### Plugins\n\nThe [browserify plugin](https://github.com/substack/node-browserify#bpluginplugin-opts) option supports the same syntax as `transform`.\n\n```javascript\n    browserify: {\n      plugin: [ 'stringify' ]\n    }\n```\n\n#### Additional Bundle Configuration\n\nYou 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](https://github.com/substack/node-browserify#external-requires):\n\n```javascript\n    browserify: {\n      configure: function(bundle) {\n        bundle.on('prebundle', function() {\n          bundle.external('foobar');\n        });\n      }\n    }\n```\n\nYou'll also need to use the `'prebundle'` event for full control over the order of transforms and plugins:\n\n```javascript\n    browserify: {\n      configure: function(bundle) {\n        bundle.once('prebundle', function() {\n          bundle.transform('babelify').plugin('proxyquireify/plugin');\n        });\n      }\n    }\n```\n\nNote that transforms must only be added once.\n\n\n### Watchify Config\n\nYou can configure the underlying [watchify](https://github.com/substack/watchify) instance via `config.watchify`. This is helpful if you need to fine tune the change detection used during `autoWatch=true`.\n\n```javascript\n    watchify: {\n      poll: true\n    }\n```\n\n\n## How it Works\n\nThis project 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`.\n\nBefore 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.\n\n\n## Detailed Configuration\n\nThe following code snippet shows a Karma configuration file with all browserify-related options.\n\n```javascript\nmodule.exports = function(karma) {\n  karma.set({\n\n    // include browserify first in used frameworks\n    frameworks: [ 'browserify', 'jasmine' ],\n\n    // add all your files here,\n    // including non-commonJS files you need to load before your test cases\n    files: [\n      'some-non-cjs-library.js',\n      'test/**/*.js'\n    ],\n\n    // add preprocessor to the files that should be\n    // processed via browserify\n    preprocessors: {\n      'test/**/*.js': [ 'browserify' ]\n    },\n\n    // see what is going on\n    logLevel: 'LOG_DEBUG',\n\n    // use autoWatch=true for quick and easy test re-execution once files change\n    autoWatch: true,\n\n    // add additional browserify configuration properties here\n    // such as transform and/or debug=true to generate source maps\n    browserify: {\n      debug: true,\n      transform: [ 'brfs' ],\n      configure: function(bundle) {\n        bundle.on('prebundle', function() {\n          bundle.external('foobar');\n        });\n      }\n    }\n  });\n};\n```\n\n\n## Related\n\nCredit goes to to the original [karma-browserify](https://github.com/xdissent/karma-browserify) and [karma-browserifast](https://github.com/cjohansen/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.\n\n\n\n## Maintainers\n\n* [Ben Drucker](https://github.com/bendrucker)\n* [Nico Rehwaldt](https://github.com/nikku)\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikku%2Fkarma-browserify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikku%2Fkarma-browserify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikku%2Fkarma-browserify/lists"}