# chai-autoload-plugins

> Automatically load chai plugins declared in package.json

Latest version **0.1.0** (published 2016-11-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install chai-autoload-plugins
pnpm add chai-autoload-plugins
yarn add chai-autoload-plugins
bun add chai-autoload-plugins
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-11-07 |
| First published | 2016-11-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Alex Mercier |
| Maintainers | amercier |
| Keywords | chai, auto, load, plugins, mocha, jasmine, jest |

## Links

- npm: https://www.npmjs.com/package/chai-autoload-plugins
- Repository: https://github.com/amercier/chai-autoload-plugins
- Homepage: https://github.com/amercier/chai-autoload-plugins#readme
- Issues: https://github.com/amercier/chai-autoload-plugins/issues
- npm.io page: https://npm.io/package/chai-autoload-plugins

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2016-11-07

## README

chai-autoload-plugins
=====================

Automatically load chai plugins declared in `package.json`.

[![Latest Stable Version](https://img.shields.io/npm/v/chai-autoload-plugins.svg)](https://www.npmjs.com/package/chai-autoload-plugins)
[![License](https://img.shields.io/npm/l/chai-autoload-plugins.svg)](https://www.npmjs.com/package/chai-autoload-plugins)
[![Build Status](https://img.shields.io/travis/amercier/chai-autoload-plugins/master.svg)](https://travis-ci.org/amercier/chai-autoload-plugins)

[![Dependency Status](http://img.shields.io/gemnasium/amercier/chai-autoload-plugins.svg)](https://gemnasium.com/amercier/chai-autoload-plugins)
[![NPM Downloads](https://img.shields.io/npm/dm/chai-autoload-plugins.svg)](https://www.npmjs.com/package/chai-autoload-plugins)
[![Test Coverage](https://img.shields.io/codecov/c/github/amercier/chai-autoload-plugins/master.svg)](https://codecov.io/github/amercier/chai-autoload-plugins?branch=master)
[![API Documentation](https://doc.esdoc.org/github.com/amercier/chai-autoload-plugins/badge.svg)](https://doc.esdoc.org/github.com/amercier/chai-autoload-plugins/)
[![Code Climate](https://img.shields.io/codeclimate/github/amercier/chai-autoload-plugins.svg)](https://codeclimate.com/github/amercier/chai-autoload-plugins)


Installation
------------

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

Usage with [Mocha](https://www.npmjs.com/package/mocha)
-------------------------------------------------------

Example using [dirty-chai](https://www.npmjs.com/package/dirty-chai):

`package.json`

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

`test.js`

```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](./specs/integration/mocha) 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`

```js
const chai = require('chai');
require('chai-autoload-plugins');

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

See [Jasmine integration tests](./specs/integration/jasmine) or
[Jest integration tests](./specs/integration/jest) 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:

```json
  "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-.*$"`).

### `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.

---
_Source: https://npm.io/package/chai-autoload-plugins · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
