Skip to content

mathewdgardner/drag-race

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

drag-race

circle coverage npm MIT licensed

Run mocha style tests in parallel.

Test Examples

The syntax is meant to be identical to mocha. There is only one caveat to this approach: each test receives a context object so that when they run in parallel the test can use the same context that the before and beforeEach used, and subsequently, the afterEach and after.

Everything is promise based using bluebird under the hood but node style callbacks are still supported.

'use strict';

const B = require('bluebird');
const expect = require('chai').expect;

describe('Passing tests', () => {
  before(() => {
    return doSomeSetup(); // Using promise
  });

  beforeEach((context, done) => {
    doSomeSpecialSetup(); // Using no async

    done(); // Using callback
  });

  afterEach((context) => {
    return doSomeSpecialTearDown(context); // Using same context that test ran in
  });

  after((done) => {
    doSomeTearDown(done); // Using callback
  });

  it('should pass', () => {
    expect(2 + 2).to.equal(4);
  });

  it('should fail', () => {
    expect(2 + 3).to.not.equal(4);
  });

  it.only('should be filtered for', () => {
    expect(2 + 2).to.equal(4);
  });

  it.skip('should be filtered out', () => {
    expect(2 + 2).to.equal(4);
  });

  xit('should be filtered out', () => {
    expect(2 + 2).to.equal(4);
  });

  it('should be pending');

  describe('nested describe', () => {

  });
});

describe.only('nested only\'ed describe', () => {

});

describe.skip('nested skipped describe', () => {

});

xdescribe('nested skipped describe', () => {

});

CLI Usage

Simply use the executable provided within ./node_modules/.bin called drag-race:

./node_modules/.bin/drag-race ./test

Or in an npm script:

"scripts": {
  "test": "drag-race ./test"
},
npm test

Concurrency

By default, all tests will run in parallel with concurrency of Infinity. You may set this number by using the -c flag:

drag-race -c 10 ./test

Observers

By default the console observer will be used to spit out whether or not tests pass. You may extend the BaseObserver class and provide either a module name or a relative path with the -o, --observer options in the command line. Simply override the super's methods and do whatever logic you want. There is no need to call super's method in the overridden methods.

License

This software is licensed under the MIT license.

About

Run mocha style tests in parallel.

Resources

License

Stars

Watchers

Forks

Packages

No packages published