chai-autoload-plugins
Automatically load chai plugins declared in package.json
.
Installation
npm install --save-dev chai-autoload-plugins
Mocha
Usage withExample using dirty-chai:
package.json
"devDependencies":
test.js
const chai = ; tobe;
Run:
node_modules/.bin/mocha --require chai-autoload-plugins test.js
See Mocha integration tests for more details.
Usage with other frameworks
The only difference is that you have to have to require chai-autoload-plugins
manually in the test
files:
test.js
const chai = ;; tobe;
See Jasmine integration tests or Jest integration tests for more details.
Options
By default, chai-autoload-plugins
look for NPM modules whose name start with chai-
or ends
with -chai
. This behavior can be overriden by declaring a chaiAutoloadPlugins
field in
package.json
. Ex:
"devDependencies": , "chaiAutoloadPlugins":
Note: if an array is given, it will include/exclude the exact names in the array. If a string is
given, it will interpret it as a regular expression (ex: "include": "^.*-chai-.*$"
).
include
Regular expression or list of plugins to include.
- Type:
String|String[]
- Default:
"(^chai|-chai$)"
exclude
Regular expression or list of plugins to exclude. Precedes include
.
- Type:
String|String[]
- Default:
[]
Notes
Browser support
This modules needs to read the contents of package.json
on the disk, and therefore is not
compatible with in-browser tests (ex: Karma). It is and will only be targeting NodeJS.