# mocha-plugin-co

> Mocha plugin to enable support for generators (using co)

Latest version **1.0.0** (published 2016-10-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install mocha-plugin-co
pnpm add mocha-plugin-co
yarn add mocha-plugin-co
bun add mocha-plugin-co
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-10-09 |
| First published | 2016-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Francois Leurent |
| Maintainers | 131 |
| Keywords | co, mocha, generators |

## Links

- npm: https://www.npmjs.com/package/mocha-plugin-co
- Repository: git@github.com:131/mocha-plugin-co
- Homepage: https://github.com/131/mocha-plugin-co
- Issues: https://github.com/131/mocha-plugin-co/issues
- npm.io page: https://npm.io/package/mocha-plugin-co

## Dependencies (1)

- [co](https://npm.io/package/co.md) ^4.0.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-10-09

## README

A [mocha](https://github.com/mochajs/mocha) plugin to enable generators (using [co](https://github.com/tj/co)) support.


## Installation
* `npm install --save-dev mocha-plugin-co`
* just add `-r mocha-plugin-co` in your mocha command line script
```
# example npm scripts
{
 "scripts" : {
    "mocha": "node node_modules/mocha/bin/_mocha -r mocha-plugin-co",
    "coverage": "node node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha -- -r mocha-plugin-co"
  }
}
```

## Usage (nothing fancy)
```
describe("sometest", function() {
  it("should do stuff", function*() {
    var start = Date.now();
    yield sleep(1000);
    expect(Date.now() - start).to.eql(1000);
  });

  it("does not change classical usage", function(done) {
    setTimeout(done, 2000);
    console.log("All good");
  });
});
```


## How It Works

The module monkey patches the `Runnable.prototype.run` method of `mocha` to enable generators. In contrast to other npm packages, this is a plugin and extends `mocha` at runtime - allowing you to use any compatible mocha version.

## License

MIT

# Related/see also
* mocha-co : [mocha](https://github.com/mochajs/mocha) fork with co support
* [co-mocha](https://github.com/blakeembrey/co-mocha) : same as this module, with some limitation (no support for errors, bigger fingerprint, disctinction between generator & non-generators in execution)


# Credits
* [131](https://github.com/131)
* [blakeembrey](https://github.com/blakeembrey) for [co-mocha](https://github.com/blakeembrey/co-mocha)


[![Build Status](https://travis-ci.org/131/mocha-plugin-co.svg?branch=master)](https://travis-ci.org/131/mocha-plugin-co)
[![Coverage Status](https://coveralls.io/repos/github/131/mocha-plugin-co/badge.svg?branch=master)](https://coveralls.io/github/131/mocha-plugin-co?branch=master)

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