Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including chai-autoload-plugins with all npm packages installed. Try it out:

require("chai/package.json"); // chai is a peer dependency. var chaiAutoloadPlugins = require("chai-autoload-plugins")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

chai-autoload-plugins v0.1.0

Automatically load chai plugins declared in package.json

chai-autoload-plugins

Automatically load chai plugins declared in package.json.

Latest Stable Version License Build Status

Dependency Status NPM Downloads Test Coverage API Documentation Code Climate

Installation

npm install --save-dev chai-autoload-plugins

Usage with Mocha

Example using dirty-chai:

package.json

  "devDependencies": {
    "chai": "^3.5.0",
    "chai-autoload-plugins": "*",
    "dirty-chai": "^1.2.2",
    "mocha": "^3.1.0"
  }

test.js

const chai = require('chai');

expect(true).to.be.true();

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 = require('chai');
require('chai-autoload-plugins');

expect(true).to.be.true();

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": {
    "chai": "^3.5.0",
    "chai-autoload-plugins": "*",
    "my-custom-chai-plugin": "*",
    "mocha": "^3.1.0"
  },
  "chaiAutoloadPlugins": {
    "include": ["my-custom-chai-plugin"],
    "exclude": []
  }

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-.*quot;).

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.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free