Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fuse-box-contrib/karma-fuse-box
Use FuseBox to preprocess files in Karma.
https://github.com/fuse-box-contrib/karma-fuse-box
fusebox karma karma-fuse-box preprocess-files test-runner
Last synced: 8 days ago
JSON representation
Use FuseBox to preprocess files in Karma.
- Host: GitHub
- URL: https://github.com/fuse-box-contrib/karma-fuse-box
- Owner: fuse-box-contrib
- License: mit
- Created: 2018-02-21T21:50:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-04T11:56:55.000Z (over 6 years ago)
- Last Synced: 2024-10-06T04:39:21.331Z (about 1 month ago)
- Topics: fusebox, karma, karma-fuse-box, preprocess-files, test-runner
- Language: JavaScript
- Homepage:
- Size: 65.4 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Install
With `npm`
```shell
npm install --save-dev karma-fuse-box
```With `yarn`
```shell
yarn add --dev karma-fuse-box
```## Usage
**karma.conf.js**
```js
const path = require("path");module.exports = config => {
config.set({
files: [
// all files ending in "_test"
{ pattern: "test/*_test.js", watched: false },
{ pattern: "test/**/*_test.js", watched: false }
// each file acts as entry point for the fusebox configuration
],preprocessors: {
// add FuseBox as preprocessor
"test/*_test.js": ["fusebox"],
"test/**/*_test.js": ["fusebox"]
},fusebox: {
// FuseBox configuration
homeDir: path.join(process.cwd(), "test/")
},// for TypeScript
mime: {
"text/x-typescript": ["ts", "tsx"]
}
});
};
```## Alternative Usage
This configuration is more performant, but you cannot run single test anymore (only the complete suite).
The above configuration generates a `FuseBox` bundle for each test. For many test cases this can result in many big files.
The alternative configuration creates a single bundle with all test cases.
**karma.conf.js**
```js
files: [
// only specify one entry point
// and require all tests in there
'test/index_test.js'
],preprocessors: {
// add fusebox as preprocessor
'test/index_test.js': [ 'fusebox' ]
},// additional arithmetic instructions needed
// unlike WebPack FuseBox will not recognize files only by source code
fuseboxInstructions: '+ test/**_test.js',
```**test/index_test.js**
```js
// use fusebox runtime API to load spec files
FuseBox.import("./**_test");
```## Options
Full list of options you can specify in your `karma.conf.js`
### `fusebox`
`FuseBox` configuration (`fuse.js`)
### `fuseboxInstructions`
String with additional instructions for file bundling
## License
[MIT](./LICENSE)