https://github.com/usrz/javascript-karma-esquire
Esquire support in Karma (as a framework)
https://github.com/usrz/javascript-karma-esquire
Last synced: 4 months ago
JSON representation
Esquire support in Karma (as a framework)
- Host: GitHub
- URL: https://github.com/usrz/javascript-karma-esquire
- Owner: usrz
- License: apache-2.0
- Created: 2014-10-30T13:04:59.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-11-25T03:34:45.000Z (over 11 years ago)
- Last Synced: 2025-08-31T02:24:33.071Z (10 months ago)
- Language: JavaScript
- Size: 172 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Karma Esquire
=============
A simple plugin to load the
[Esquire](https://github.com/usrz/javascript-esquire)
library and (optionally) a number of scripts before running
[Karma](http://karma-runner.github.io/).
### Installation
Install with [NPM](http://www.npmjs.com/):
```sh
npm install --save-dev karma-esquire
```
Then just add the `esquire` module to your listed `frameworks` in _karma.conf.js_.
```js
module.exports = function(config) {
config.set({
// ...
frameworks: ['esquire', /* ... */ ],
files: [
// ...
]
};
```
### Loading scripts
When working with [Karma](http://karma-runner.github.io/) for unit testing, the
`Esquire.karma(...)` method can be used to specify what scripts to be loaded
with each run.
The `Esquire.karma(...)` method takes either a `RegExp` or a callback `function`:
This method can be invoked _multiple_ times, and *all* callbacks or expressions
will be evaluated. If *any* of them matches, the script will be loaded.
##### Regular Expressions
When invoked with a `RegExp`, any file matching the expression will be loaded.
```js
// This will load all '/tests/deferred/....js' files
Esquire.karma(/^\/tests\/deferred\/.\.js$/);
```
##### Callback functions
When invoked with a callback `function`, the callback will be invoked once for
every file known to `Karma` and if the callback returns a _truthy_ value,
said file will be loaded as a script dependency.
```js
// The callback function will be invoked for every file, and said
// file will be loaded if the function returns a truthy value
Esquire.karma(function(file) {
return ...;
});
```
### License
[Apache License, Version 2.0](Apache License)