How to use the mocha.parallel 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 clusterio / factorioClusterio / test / master.js View on Github external
describe('Master testing', function() {
	describe('#GET /api/getFactorioLocale', function() {
		it('should get the basegame factorio locale', async function() {
			let res = await get('/api/getFactorioLocale');
			let object = res.body;

			// test that it is looks like a factorio locale
			assert.equal(typeof object, "object");
			assert.equal(object["entity-name"]["fish"], "Fish");
			assert.equal(object["entity-name"]["small-lamp"], "Lamp");
		});
	});
	// describe("#GET /api/")
	parallel("#GET static website data", function() {
		this.timeout(6000);

		let paths = ["/", "/nodes", "/settings", "/nodeDetails"];
		for (let path of paths) {
			it(`sends some HTML when accessing ${path}`, () => getValidate(path));
		}
	});

	describe("class SocketIOServerConnector", function() {
		let testConnector = new master._SocketIOServerConnector(new mock.MockSocket());
		describe(".disconnect()", function() {
			it("should call disconnect on the socket", function() {
				testConnector._socket.disconnectCalled = false;
				testConnector.disconnect();
				assert(testConnector._socket.disconnectCalled, "Disconnect was not called");
			});
github wikimedia / restbase / test / features / errors / invalid_request.js View on Github external
'use strict';

const parallel = require('mocha.parallel');
const assert  = require('../../utils/assert.js');
const preq    = require('preq');
const Server  = require('../../utils/server.js');
const nock    = require('nock');

parallel('400 handling', function() {
    this.timeout(20000);
    const server = new Server();
    let siteInfo;
    let revisionInfo;
    before(() => {
        if (!nock.isActive()) {
            nock.activate();
        }
        return server.start()
        .then(() => {
            // Fetch real siteInfo to return from a mock
            return preq.post({
                uri: server.config.apiURL('en.wikipedia.beta.wmflabs.org'),
                body: {
                    action: 'query',
                    meta: 'siteinfo|filerepoinfo',
github SqueezerIO / squeezer / test / lib / integration.js View on Github external
it('should run the "version" command', (done) => {
    shtest(`${baseCommand} version`, done, /CLI version/);
  });

  parallel('create projects based on all available templates', () => {
    const cmd = `cd ${projectsBuildPath} && ${baseCommand} create --project #template --template #template --email test@squeezer.io --noChecksums true`;
    testTemplates(cmd, /Project successfully created/);
  });

  describe('configuring clouds credentials', () => {
    const cmd = `cd ${projectsBuildPath}/#template && ${baseCommand} config --setting aws_profile --value ${awsTestProfile}`;
    testTemplates(cmd, /Done !/);
  });

  parallel('installing packages on all projects', () => {
    const cmd = `cd ${projectsBuildPath}/#template && ${baseCommand} install`;
    testTemplates(cmd, /Installed !/);
  });

  parallel('development compile current projects', () => {
    const cmd = `cd ${projectsBuildPath}/#template && ${baseCommand} compile`;
    testTemplates(cmd, /Compiled !/);
  });

  parallel('cloud compile all projects', () => {
    const cmd = `cd ${projectsBuildPath}/#template && ${baseCommand} compile --cloud`;
    testTemplates(cmd, /Compiled !/);
  });

  parallel('deploying all projects', () => {
    const cmd = `cd ${projectsBuildPath}/#template && ${baseCommand} deploy`;
github wikimedia / restbase / test / features / metrics.js View on Github external
'use strict';

const assert = require('../utils/assert.js');
const Server = require('../utils/server.js');
const preq   = require('preq');
const parallel = require('mocha.parallel');

parallel('Metrics', function() {
    this.timeout(20000);
    const server = new Server();
    before(() => server.start());
    after(() => server.stop());

    it('Should get page views per page', () => {
        return preq.get({
            uri: `${server.config.baseURL('wikimedia.org')}/metrics/pageviews/per-article/en.wikipedia/all-access/all-agents/Main_Page/daily/2016010100/2016010100`
        })
        .then((res) => {
            assert.deepEqual(res.status, 200);
            assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8');
            assert.deepEqual(res.body, {
                items: [
                    {
                        project: 'en.wikipedia',
github binary-com / binary-live-api / test / payment-test-spec.js View on Github external
import describe from 'mocha.parallel';
import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
chai.use(chaiAsPromised);
import 'babel-polyfill';
import LiveApi from '../src/LiveApi';
import ws from 'ws';

describe('payment', () => {
    let liveApi;
    let token = '4yFDEnFI3EpnZ7M';

    beforeEach(() => {
        liveApi = new LiveApi({ websocket: ws });
    });

    it('should be able to get cashierLock status', async () => {
		await liveApi.authorize(token);
		const response = await liveApi.getCashierLockStatus();
		expect(response).to.have.property('cashier_password');
    });

    it('should be able to Lock Cashier', () => {
		expect(() =>
            liveApi.setCashierLock({ lock_password: '12345768' }))
github johntitus / node-horseman / test / index.js View on Github external
it('should keep resolution value after log', function() {
			var horseman = new Horseman({
				timeout: defaultTimeout,
			});
			return horseman
				.open(serverUrl)
				.return(1)
				.log(undefined)
				.close()
				.should.eventually
				.equal(1);
		});
	});

	parallel('Inject jQuery', function() {
		it('should inject jQuery', function() {
			var horseman = new Horseman({
				timeout: defaultTimeout,
			});
			return horseman
				.open('http://www.google.com')
				.evaluate(function() {
					return typeof jQuery;
				})
				.close()
				.should.eventually
				.equal('function');
		});

		it('should not inject jQuery', function() {
			var horseman = new Horseman({
github nodeca / url-unshort / test / services.js View on Github external
} else {
        expected = expected.concat(Object.keys(d));
      }
    });

    Object.keys(urls).forEach(function (url) {
      let u = URL.parse(url);

      actual.push(u.host);
    });

    assert.deepEqual(expected.map(truncateDomain).map(punycode.toUnicode).sort(),
                     actual.map(truncateDomain).map(punycode.toUnicode).sort());
  });

  parallel('ping services', function () {
    let links = Object.keys(urls);

    if (!checkAll) { links = links.slice(0, 1); }

    links.forEach(function (link) {

      it(link, function () {
        return uu.expand(link).then(function (result) {
          assert.strictEqual(result, urls[link]);
        });
      });
    });
  });

});
github johntitus / node-horseman / test / index.js View on Github external
function evaluation(bool) {
	var title = 'Evaluation ' + ((bool) ? 'with' : 'without') + ' jQuery';

	parallel(title, function() {
		after(function unlinkFiles() {
			return Promise
				.fromCallback(function(done) {
					return fs.stat('test.html', done);
				})
				.call('isFile')
				.catch(function() {})
				.then(function(isFile) {
					if (!isFile) {
						return;
					}
					return Promise.fromCallback(function(done) {
						return fs.unlink('test.html', done);
					});
				});
		});
github thenativeweb / roboter / test / integration / roboterTests.js View on Github external
fs.readdirSync(__dirname).forEach(task => {
    const taskDirectory = path.join(__dirname, task);

    if (!fs.statSync(taskDirectory).isDirectory()) {
      return;
    }

    parallel(task, () => {
      fs.readdirSync(taskDirectory).forEach(testCase => {
        const testCaseDirectory = path.join(taskDirectory, testCase);

        if (!fs.statSync(testCaseDirectory).isDirectory()) {
          return;
        }

        if (!shallTestCaseBeExecuted({
          task,
          testCase,
          args: process.argv[10]
        })) {
          return;
        }

        createTest({ task, testCase, directory: testCaseDirectory, roboterPackagePath });
github SqueezerIO / squeezer / test / lib / integration.js View on Github external
parallel('create projects based on all available templates', () => {
    const cmd = `cd ${projectsBuildPath} && ${baseCommand} create --project #template --template #template --email test@squeezer.io --noChecksums true`;
    testTemplates(cmd, /Project successfully created/);
  });

  describe('configuring clouds credentials', () => {
    const cmd = `cd ${projectsBuildPath}/#template && ${baseCommand} config --setting aws_profile --value ${awsTestProfile}`;
    testTemplates(cmd, /Done !/);
  });

  parallel('installing packages on all projects', () => {
    const cmd = `cd ${projectsBuildPath}/#template && ${baseCommand} install`;
    testTemplates(cmd, /Installed !/);
  });

  parallel('development compile current projects', () => {
    const cmd = `cd ${projectsBuildPath}/#template && ${baseCommand} compile`;
    testTemplates(cmd, /Compiled !/);
  });

  parallel('cloud compile all projects', () => {
    const cmd = `cd ${projectsBuildPath}/#template && ${baseCommand} compile --cloud`;
    testTemplates(cmd, /Compiled !/);
  });

  parallel('deploying all projects', () => {
    const cmd = `cd ${projectsBuildPath}/#template && ${baseCommand} deploy`;
    testTemplates(cmd, /Saving checksums/);
  });

  parallel('testing all projects', () => {
    const cmd = `sh -c 'cd ${projectsBuildPath}/#template && ${baseCommand} test'`;