Skip to content

Instantly share code, notes, and snippets.

@lennym
Created March 25, 2014 13:21
Show Gist options
  • Save lennym/9761653 to your computer and use it in GitHub Desktop.
Save lennym/9761653 to your computer and use it in GitHub Desktop.
Programmatic/dynamic Mocha test construction
var Mocha = require('mocha'),
expect = require('chai').expect;
var mocha = new Mocha({
reporter: 'spec'
});
var dashboards = Mocha.Suite.create(mocha.suite, 'dashboards');
var subsuite = Mocha.Suite.create(dashboards, 'something');
subsuite.addTest(new Mocha.Test('a thing', function () {
expect(1).to.equal(1);
}));
dashboards.beforeAll(function () {
console.log('BEFORE');
});
dashboards.afterAll(function () {
console.log('AFTER');
});
mocha.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment