karma-esquire
v1.0.1
Published
Esquire support in Karma (as a framework)
Downloads
4
Readme
Karma Esquire
A simple plugin to load the Esquire library and (optionally) a number of scripts before running Karma.
Installation
Install with NPM:
npm install --save-dev karma-esquire
Then just add the esquire
module to your listed frameworks
in karma.conf.js.
module.exports = function(config) {
config.set({
// ...
frameworks: ['esquire', /* ... */ ],
files: [
// ...
]
};
Loading scripts
When working with Karma 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.
// 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.
// 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)