mocha-plugin-highland

0.0.2 • Public • Published

mocha-plugin-highland

Build Status Coverage Status

A mocha plugin to enable Highland stream (using highland) support.

Installation

  • npm install --save-dev mocha-plugin-highland
  • just add -r mocha-plugin-highland in your mocha command line npm script in package.json
{
  "scripts" : {
    "test": "node node_modules/mocha/bin/_mocha -r mocha-plugin-highland",
    "coverage": "node node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha -- -r mocha-plugin-highland"
  }
}

Example Usage

require('should');
var fs = require('fs');
var _ = require('highland');
 
var readFile = _.wrapCallback(fs.readFile);
 
describe('sometest', function () {
  it('should read file and output a collection of names', () => 
    readFile('myfile.txt')
    .map(toUpperCase)
    .map(function (x) {
        return {name: x};
    })
    .collect()
    .tap(arr => {
        arr.should.containDeep([
            { name: 'Joe' },
            { name: 'Emma' },
            { name: 'Harry' },
            { name: 'Rachel' }
        ]);
    })
  );
 
  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 the usage of Highland streams. 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

Dependents (0)

Package Sidebar

Install

npm i mocha-plugin-highland

Weekly Downloads

2

Version

0.0.2

License

MIT

Last publish

Collaborators

  • robertstettner