Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-mocha-co

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-mocha-co

Run Mocha tests with co generators

  • 0.4.1-co.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by80%
Maintainers
1
Weekly downloads
 
Created
Source

Information

This gulp plugin is based on Sindre Sorhus gulp-mocha plugin, but pointing to mocha-co

Use

In order to have your tests running with mocha-co you need to launch gulp with the ES6 flag '--harmony'

You can do it with

node --harmony `which gulp`

or creating an alias

alias gulp='node --harmony `which gulp`'

Then you can run your tasks as normal

gulp test

Install

Install with npm

npm install --save-dev gulp-mocha-co

Example

var gulp = require('gulp');
var mocha = require('gulp-mocha-co');

gulp.task('default', function () {
  gulp.src('test.js')
    .pipe(mocha({reporter: 'nyan'}));
});

Code with generators


describe('My test with generators', function(){
  before(function *(){
    yield whatever.doSomething()
  });

  beforeEach(function*(){
    var returnedThing = yield whatever.returnWhatever()
  });

  it('Should have the things', function*(){
    var thingsExist = yield parser.checkIfThingsExist();
    expect(thingsExist).to.equals(true);
  });
});

Alternative

Btw, you can just keep using gulp-mocha and good ol mocha and add this code to your tests:

var co = require('co');

// ....

it('should work', function(done){
  co(function *(){
    yield whatever;
  })(done)
})

See this issue

API

mocha(options)

options.ui

Type: String
Default: bdd
Values: bdd, tdd, qunit, exports

The interface to use.

options.reporter

Type: String
Default: dot
Values: reporters

The reporter that will be used.

This option can also be used to utilize third-party reporters. For example if you npm install mocha-lcov-reporter you can then do use mocha-lcov-reporter as value.

options.globals

Type: Array

Accepted globals.

options.timeout

Type: Number
Default: 2000

Test-case timeout in milliseconds.

options.bail

Type: Boolean
Default: false

Bail on the first test failure.

options.ignoreLeaks

Type: Boolean
Default: false

Ignore global leaks.

options.grep

Type: String

Only run tests matching the given pattern which is internally compiled to a RegExp.

License

Based on Sindre Sorhus work MIT © Sindre Sorhus

Keywords

FAQs

Package last updated on 26 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc