UNPKG

1.13 kBJavaScriptView Raw
1/* eslint no-invalid-this: 0, no-irregular-whitespace: 0, global-require: 0 */
2"use strict";
3
4//
5// Provide Mocha support for:
6// - Non-browser testing, or regular node.js mocha tests
7//
8
9var _ = require("lodash");
10var mochaSettings = require("./settings");
11
12var MochaTestRun = function (options) {
13 _.extend(this, options);
14};
15
16// return the command line path to the test framework binary
17MochaTestRun.prototype.getCommand = function () {
18 return "./node_modules/.bin/mocha";
19};
20
21// return the environment
22MochaTestRun.prototype.getEnvironment = function (env) {
23 return _.extend({}, env);
24};
25
26MochaTestRun.prototype.getArguments = function () {
27 var grepString = this.locator.name;
28
29 var escapees = "\\^$[]+*.()\"";
30 escapees.split("").forEach(function (ch) {
31 grepString = grepString.split(ch).join("\\" + ch);
32 });
33
34 var args = [
35 "--mocking_port=" + this.mockingPort,
36 "--worker=1",
37 "-g",
38 grepString
39 ];
40
41 if (mochaSettings.mochaOpts) {
42 args.push("--opts", mochaSettings.mochaOpts);
43 }
44
45 args = args.concat(mochaSettings.mochaTestFolders);
46
47 return args;
48};
49
50module.exports = MochaTestRun;