How to use the mocha.Suite function in mocha

To help you get started, we’ve selected a few mocha examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitovi / testee / lib / reporter / reporter.js View on Github external
function startRun(data) {
    // When a new test run begins, start a root suite with the formatted environment
    // information as the title
    var suite = mochaObjects[data.id] = new mocha.Suite(data.environment, {});
    buffers.add(data.id).emit('suite', suite);
  }
github bitovi / testee / lib / reporter / index.js View on Github external
startRun: function(data) {
    debug('starting run', data);
    this.buffers.updateCache(data);

    var suiteTitle = data.title;

    if(data.environment) {
      // When a new test run begins, start a root suite with the formatted environment
      // information as the title
      var agent = useragent.parse(data.environment);
      var file = url.parse(data.file);

      suiteTitle = data.runner + ' "' + file.pathname.substring(1) + '" on ' + agent.toString() + ':';
    }

    var suite = this._mochaObjects[data.id] = new mocha.Suite(suiteTitle, {});
    this.buffers.add(data.id).emit('suite', suite);
  },
github sheremetyev / texts.js / test / run.js View on Github external
function loadTests(mainSuite) {
  var fs = require('fs');
  
  var mainSuite = new mocha.Suite('', new mocha.Context);
  
  fs.readdirSync(__dirname).forEach(function(testdirname) {
    var testdir = __dirname + '/' + testdirname;
    if (fs.statSync(testdir).isDirectory()) {
  
      var suite = new mocha.Suite.create(mainSuite, testdirname);
      fs.readdirSync(testdir).forEach(function(testfilename) {
        if (testfilename.substr(-5) === '.test') {
          
          var testfile = testdir + '/' + testfilename;
          var testname = testfilename.slice(0, -5);

          var test = new mocha.Test(testname, function(done) {
            runTestFile(testfile, done);
          });
github jgonera / webspecter / lib / engine.js View on Github external
var Engine = exports.Engine = function Engine(options) {
  this.options = options;
  this.rootSuite = new mocha.Suite('', new mocha.Context);
  this.rootSuite.timeout(10000);
  ReporterBase.slow = 1000;
  this.ui = mocha.interfaces['bdd'];
  this.ui(this.rootSuite);
  this.featureManager = new FeatureManager(this.rootSuite);

  global.assert = require('chai').assert;
  global.should = require('chai').should();
  global.expect = require('chai').expect;
  global.wait = require('./keywords/wait');
  global.parallelize = require('./keywords/parallelize');
  global.feature = require('./keywords/feature')(this);
  
  environment.load(utils.findEnvFile(options.path));
  environment.config.console = options.console;
  Reporter = require('mocha/lib/reporters/' + (options.reporter || environment.config.reporter || 'spec'));
github twigjs / twig.js / node_modules / mocha / mocha.js View on Github external
;(function(){
  var suite = new mocha.Suite;
  var Reporter = mocha.reporters.HTML;

  function parse(qs) {
    return qs
      .replace('?', '')
      .split('&')
      .reduce(function(obj, pair){
        var i = pair.indexOf('=')
          , key = pair.slice(0, i)
          , val = pair.slice(++i);

        obj[key] = decodeURIComponent(val);
        return obj;
      }, {});
  }
github Codeception / CodeceptJS / lib / command / run-workers.js View on Github external
function repackTest(test) {
  test = Object.assign(new Test(test.title || '', () => { }), test);
  test.parent = Object.assign(new Suite(test.parent.title), test.parent);
  return test;
}
github Codeception / CodeceptJS / lib / command / run-workers.js View on Github external
function repackSuite(suite) {
  return Object.assign(new Suite(suite.title), suite);
}
github gagarinjs / meteor-mocha / packages / gagarin-mocha-cli / lib / Receiver.js View on Github external
Receiver.prototype.createSuite = function createSuite(rawSuite) {
  var suite = new Mocha.Suite(rawSuite.title);
  suite.parent = this.suite;
  return suite;
};
github fat / haunt / lib / repo.js View on Github external
async.forEachSeries(issues, function (issue, next) {

            reporterType != 'Base' && template.render('events/test-title', { type: type, url: issue.data.html_url });

            var suite = new mocha.Suite(type, new mocha.Context);

            for (var key in this.tests[type]) {

                var fn = this.tests[type][key];

                switch (key) {
                    case 'before':
                        suite.beforeAll(fn.bind(fn, issue.exports));
                        break;
                    case 'after':
                        suite.afterAll(fn.bind(fn, issue.exports));
                        break;
                    default:
                        suite.addTest(new mocha.Test(key, fn.bind(fn, issue.exports)));
                }