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 { config
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' filesEsquire;
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 valueEsquire;