Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
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);
},
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);
});
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'));
;(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;
}, {});
}
function repackTest(test) {
test = Object.assign(new Test(test.title || '', () => { }), test);
test.parent = Object.assign(new Suite(test.parent.title), test.parent);
return test;
}
function repackSuite(suite) {
return Object.assign(new Suite(suite.title), suite);
}
Receiver.prototype.createSuite = function createSuite(rawSuite) {
var suite = new Mocha.Suite(rawSuite.title);
suite.parent = this.suite;
return suite;
};
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)));
}