mocha 3.0.2 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +103 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/bin/_mocha +170 -104
- package/bin/mocha +22 -13
- package/bin/options.js +7 -5
- package/browser-entry.js +43 -22
- package/lib/browser/.eslintrc.yaml +4 -0
- package/lib/browser/debug.js +6 -3
- package/lib/browser/events.js +11 -9
- package/lib/browser/progress.js +9 -7
- package/lib/browser/tty.js +4 -2
- package/lib/context.js +11 -9
- package/lib/hook.js +4 -2
- package/lib/interfaces/bdd.js +11 -9
- package/lib/interfaces/common.js +16 -14
- package/lib/interfaces/exports.js +4 -2
- package/lib/interfaces/index.js +2 -0
- package/lib/interfaces/qunit.js +12 -8
- package/lib/interfaces/tdd.js +9 -7
- package/lib/mocha.js +36 -34
- package/lib/ms.js +12 -10
- package/lib/pending.js +2 -1
- package/lib/reporters/base.js +52 -50
- package/lib/reporters/doc.js +8 -6
- package/lib/reporters/dot.js +9 -7
- package/lib/reporters/html.js +32 -30
- package/lib/reporters/index.js +2 -0
- package/lib/reporters/json-stream.js +8 -6
- package/lib/reporters/json.js +11 -9
- package/lib/reporters/landing.js +8 -6
- package/lib/reporters/list.js +13 -11
- package/lib/reporters/markdown.js +12 -10
- package/lib/reporters/min.js +4 -2
- package/lib/reporters/nyan.js +22 -20
- package/lib/reporters/progress.js +7 -5
- package/lib/reporters/spec.js +17 -15
- package/lib/reporters/tap.js +10 -8
- package/lib/reporters/xunit.js +14 -12
- package/lib/runnable.js +43 -32
- package/lib/runner.js +78 -63
- package/lib/suite.js +24 -22
- package/lib/test.js +4 -2
- package/lib/utils.js +115 -90
- package/mocha.js +1185 -800
- package/package.json +9 -2
- package/lib/interfaces/bdd.js.orig +0 -118
- package/lib/mocha.js.orig +0 -532
- package/lib/runnable.js.orig +0 -378
- package/lib/runner.js.orig +0 -934
- package/lib/suite.js.orig +0 -418
- package/lib/test.js.orig +0 -52
- package/lib/utils.js.orig +0 -758
package/lib/interfaces/common.js
CHANGED
|
@@ -10,17 +10,17 @@ var Suite = require('../suite');
|
|
|
10
10
|
* @param {Mocha} mocha
|
|
11
11
|
* @return {Object} An object containing common functions.
|
|
12
12
|
*/
|
|
13
|
-
module.exports = function(suites, context, mocha) {
|
|
13
|
+
module.exports = function (suites, context, mocha) {
|
|
14
14
|
return {
|
|
15
15
|
/**
|
|
16
16
|
* This is only present if flag --delay is passed into Mocha. It triggers
|
|
17
17
|
* root suite execution.
|
|
18
18
|
*
|
|
19
|
-
* @param {Suite} suite The root
|
|
19
|
+
* @param {Suite} suite The root suite.
|
|
20
20
|
* @return {Function} A function which runs the root suite
|
|
21
21
|
*/
|
|
22
|
-
runWithSuite: function runWithSuite(suite) {
|
|
23
|
-
return function run() {
|
|
22
|
+
runWithSuite: function runWithSuite (suite) {
|
|
23
|
+
return function run () {
|
|
24
24
|
suite.run();
|
|
25
25
|
};
|
|
26
26
|
},
|
|
@@ -31,7 +31,7 @@ module.exports = function(suites, context, mocha) {
|
|
|
31
31
|
* @param {string} name
|
|
32
32
|
* @param {Function} fn
|
|
33
33
|
*/
|
|
34
|
-
before: function(name, fn) {
|
|
34
|
+
before: function (name, fn) {
|
|
35
35
|
suites[0].beforeAll(name, fn);
|
|
36
36
|
},
|
|
37
37
|
|
|
@@ -41,7 +41,7 @@ module.exports = function(suites, context, mocha) {
|
|
|
41
41
|
* @param {string} name
|
|
42
42
|
* @param {Function} fn
|
|
43
43
|
*/
|
|
44
|
-
after: function(name, fn) {
|
|
44
|
+
after: function (name, fn) {
|
|
45
45
|
suites[0].afterAll(name, fn);
|
|
46
46
|
},
|
|
47
47
|
|
|
@@ -51,7 +51,7 @@ module.exports = function(suites, context, mocha) {
|
|
|
51
51
|
* @param {string} name
|
|
52
52
|
* @param {Function} fn
|
|
53
53
|
*/
|
|
54
|
-
beforeEach: function(name, fn) {
|
|
54
|
+
beforeEach: function (name, fn) {
|
|
55
55
|
suites[0].beforeEach(name, fn);
|
|
56
56
|
},
|
|
57
57
|
|
|
@@ -61,7 +61,7 @@ module.exports = function(suites, context, mocha) {
|
|
|
61
61
|
* @param {string} name
|
|
62
62
|
* @param {Function} fn
|
|
63
63
|
*/
|
|
64
|
-
afterEach: function(name, fn) {
|
|
64
|
+
afterEach: function (name, fn) {
|
|
65
65
|
suites[0].afterEach(name, fn);
|
|
66
66
|
},
|
|
67
67
|
|
|
@@ -73,7 +73,7 @@ module.exports = function(suites, context, mocha) {
|
|
|
73
73
|
* @param {Object} opts
|
|
74
74
|
* @returns {Suite}
|
|
75
75
|
*/
|
|
76
|
-
only: function only(opts) {
|
|
76
|
+
only: function only (opts) {
|
|
77
77
|
mocha.options.hasOnly = true;
|
|
78
78
|
opts.isOnly = true;
|
|
79
79
|
return this.create(opts);
|
|
@@ -86,7 +86,7 @@ module.exports = function(suites, context, mocha) {
|
|
|
86
86
|
* @param {Object} opts
|
|
87
87
|
* @returns {Suite}
|
|
88
88
|
*/
|
|
89
|
-
skip: function skip(opts) {
|
|
89
|
+
skip: function skip (opts) {
|
|
90
90
|
opts.pending = true;
|
|
91
91
|
return this.create(opts);
|
|
92
92
|
},
|
|
@@ -101,7 +101,7 @@ module.exports = function(suites, context, mocha) {
|
|
|
101
101
|
* @param {boolean} [opts.isOnly] Is Suite exclusive?
|
|
102
102
|
* @returns {Suite}
|
|
103
103
|
*/
|
|
104
|
-
create: function create(opts) {
|
|
104
|
+
create: function create (opts) {
|
|
105
105
|
var suite = Suite.create(suites[0], opts.title);
|
|
106
106
|
suite.pending = Boolean(opts.pending);
|
|
107
107
|
suite.file = opts.file;
|
|
@@ -113,6 +113,8 @@ module.exports = function(suites, context, mocha) {
|
|
|
113
113
|
if (typeof opts.fn === 'function') {
|
|
114
114
|
opts.fn.call(suite);
|
|
115
115
|
suites.shift();
|
|
116
|
+
} else if (typeof opts.fn === 'undefined' && !suite.pending) {
|
|
117
|
+
throw new Error('Suite "' + suite.fullTitle() + '" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.');
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
return suite;
|
|
@@ -128,7 +130,7 @@ module.exports = function(suites, context, mocha) {
|
|
|
128
130
|
* @param {Function} test
|
|
129
131
|
* @returns {*}
|
|
130
132
|
*/
|
|
131
|
-
only: function(mocha, test) {
|
|
133
|
+
only: function (mocha, test) {
|
|
132
134
|
test.parent._onlyTests = test.parent._onlyTests.concat(test);
|
|
133
135
|
mocha.options.hasOnly = true;
|
|
134
136
|
return test;
|
|
@@ -139,7 +141,7 @@ module.exports = function(suites, context, mocha) {
|
|
|
139
141
|
*
|
|
140
142
|
* @param {string} title
|
|
141
143
|
*/
|
|
142
|
-
skip: function(title) {
|
|
144
|
+
skip: function (title) {
|
|
143
145
|
context.test(title);
|
|
144
146
|
},
|
|
145
147
|
|
|
@@ -148,7 +150,7 @@ module.exports = function(suites, context, mocha) {
|
|
|
148
150
|
*
|
|
149
151
|
* @param {number} n
|
|
150
152
|
*/
|
|
151
|
-
retries: function(n) {
|
|
153
|
+
retries: function (n) {
|
|
152
154
|
context.retries(n);
|
|
153
155
|
}
|
|
154
156
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Module dependencies.
|
|
3
5
|
*/
|
|
@@ -22,12 +24,12 @@ var Test = require('../test');
|
|
|
22
24
|
*
|
|
23
25
|
* @param {Suite} suite Root suite.
|
|
24
26
|
*/
|
|
25
|
-
module.exports = function(suite) {
|
|
27
|
+
module.exports = function (suite) {
|
|
26
28
|
var suites = [suite];
|
|
27
29
|
|
|
28
30
|
suite.on('require', visit);
|
|
29
31
|
|
|
30
|
-
function visit(obj, file) {
|
|
32
|
+
function visit (obj, file) {
|
|
31
33
|
var suite;
|
|
32
34
|
for (var key in obj) {
|
|
33
35
|
if (typeof obj[key] === 'function') {
|
package/lib/interfaces/index.js
CHANGED
package/lib/interfaces/qunit.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Module dependencies.
|
|
3
5
|
*/
|
|
@@ -29,10 +31,10 @@ var Test = require('../test');
|
|
|
29
31
|
*
|
|
30
32
|
* @param {Suite} suite Root suite.
|
|
31
33
|
*/
|
|
32
|
-
module.exports = function(suite) {
|
|
34
|
+
module.exports = function (suite) {
|
|
33
35
|
var suites = [suite];
|
|
34
36
|
|
|
35
|
-
suite.on('pre-require', function(context, file, mocha) {
|
|
37
|
+
suite.on('pre-require', function (context, file, mocha) {
|
|
36
38
|
var common = require('./common')(suites, context, mocha);
|
|
37
39
|
|
|
38
40
|
context.before = common.before;
|
|
@@ -44,13 +46,14 @@ module.exports = function(suite) {
|
|
|
44
46
|
* Describe a "suite" with the given `title`.
|
|
45
47
|
*/
|
|
46
48
|
|
|
47
|
-
context.suite = function(title) {
|
|
49
|
+
context.suite = function (title) {
|
|
48
50
|
if (suites.length > 1) {
|
|
49
51
|
suites.shift();
|
|
50
52
|
}
|
|
51
53
|
return common.suite.create({
|
|
52
54
|
title: title,
|
|
53
|
-
file: file
|
|
55
|
+
file: file,
|
|
56
|
+
fn: false
|
|
54
57
|
});
|
|
55
58
|
};
|
|
56
59
|
|
|
@@ -58,13 +61,14 @@ module.exports = function(suite) {
|
|
|
58
61
|
* Exclusive Suite.
|
|
59
62
|
*/
|
|
60
63
|
|
|
61
|
-
context.suite.only = function(title) {
|
|
64
|
+
context.suite.only = function (title) {
|
|
62
65
|
if (suites.length > 1) {
|
|
63
66
|
suites.shift();
|
|
64
67
|
}
|
|
65
68
|
return common.suite.only({
|
|
66
69
|
title: title,
|
|
67
|
-
file: file
|
|
70
|
+
file: file,
|
|
71
|
+
fn: false
|
|
68
72
|
});
|
|
69
73
|
};
|
|
70
74
|
|
|
@@ -74,7 +78,7 @@ module.exports = function(suite) {
|
|
|
74
78
|
* acting as a thunk.
|
|
75
79
|
*/
|
|
76
80
|
|
|
77
|
-
context.test = function(title, fn) {
|
|
81
|
+
context.test = function (title, fn) {
|
|
78
82
|
var test = new Test(title, fn);
|
|
79
83
|
test.file = file;
|
|
80
84
|
suites[0].addTest(test);
|
|
@@ -85,7 +89,7 @@ module.exports = function(suite) {
|
|
|
85
89
|
* Exclusive test-case.
|
|
86
90
|
*/
|
|
87
91
|
|
|
88
|
-
context.test.only = function(title, fn) {
|
|
92
|
+
context.test.only = function (title, fn) {
|
|
89
93
|
return common.test.only(mocha, context.test(title, fn));
|
|
90
94
|
};
|
|
91
95
|
|
package/lib/interfaces/tdd.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Module dependencies.
|
|
3
5
|
*/
|
|
@@ -29,10 +31,10 @@ var Test = require('../test');
|
|
|
29
31
|
*
|
|
30
32
|
* @param {Suite} suite Root suite.
|
|
31
33
|
*/
|
|
32
|
-
module.exports = function(suite) {
|
|
34
|
+
module.exports = function (suite) {
|
|
33
35
|
var suites = [suite];
|
|
34
36
|
|
|
35
|
-
suite.on('pre-require', function(context, file, mocha) {
|
|
37
|
+
suite.on('pre-require', function (context, file, mocha) {
|
|
36
38
|
var common = require('./common')(suites, context, mocha);
|
|
37
39
|
|
|
38
40
|
context.setup = common.beforeEach;
|
|
@@ -45,7 +47,7 @@ module.exports = function(suite) {
|
|
|
45
47
|
* Describe a "suite" with the given `title` and callback `fn` containing
|
|
46
48
|
* nested suites and/or tests.
|
|
47
49
|
*/
|
|
48
|
-
context.suite = function(title, fn) {
|
|
50
|
+
context.suite = function (title, fn) {
|
|
49
51
|
return common.suite.create({
|
|
50
52
|
title: title,
|
|
51
53
|
file: file,
|
|
@@ -56,7 +58,7 @@ module.exports = function(suite) {
|
|
|
56
58
|
/**
|
|
57
59
|
* Pending suite.
|
|
58
60
|
*/
|
|
59
|
-
context.suite.skip = function(title, fn) {
|
|
61
|
+
context.suite.skip = function (title, fn) {
|
|
60
62
|
return common.suite.skip({
|
|
61
63
|
title: title,
|
|
62
64
|
file: file,
|
|
@@ -67,7 +69,7 @@ module.exports = function(suite) {
|
|
|
67
69
|
/**
|
|
68
70
|
* Exclusive test-case.
|
|
69
71
|
*/
|
|
70
|
-
context.suite.only = function(title, fn) {
|
|
72
|
+
context.suite.only = function (title, fn) {
|
|
71
73
|
return common.suite.only({
|
|
72
74
|
title: title,
|
|
73
75
|
file: file,
|
|
@@ -79,7 +81,7 @@ module.exports = function(suite) {
|
|
|
79
81
|
* Describe a specification or test-case with the given `title` and
|
|
80
82
|
* callback `fn` acting as a thunk.
|
|
81
83
|
*/
|
|
82
|
-
context.test = function(title, fn) {
|
|
84
|
+
context.test = function (title, fn) {
|
|
83
85
|
var suite = suites[0];
|
|
84
86
|
if (suite.isPending()) {
|
|
85
87
|
fn = null;
|
|
@@ -94,7 +96,7 @@ module.exports = function(suite) {
|
|
|
94
96
|
* Exclusive test-case.
|
|
95
97
|
*/
|
|
96
98
|
|
|
97
|
-
context.test.only = function(title, fn) {
|
|
99
|
+
context.test.only = function (title, fn) {
|
|
98
100
|
return common.test.only(mocha, context.test(title, fn));
|
|
99
101
|
};
|
|
100
102
|
|
package/lib/mocha.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/*!
|
|
2
4
|
* mocha
|
|
3
5
|
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
|
|
@@ -49,7 +51,7 @@ exports.Test = require('./test');
|
|
|
49
51
|
* @param {string} name
|
|
50
52
|
* @return {string}
|
|
51
53
|
*/
|
|
52
|
-
function image(name) {
|
|
54
|
+
function image (name) {
|
|
53
55
|
return path.join(__dirname, '../images', name + '.png');
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -72,7 +74,7 @@ function image(name) {
|
|
|
72
74
|
* @param {Object} options
|
|
73
75
|
* @api public
|
|
74
76
|
*/
|
|
75
|
-
function Mocha(options) {
|
|
77
|
+
function Mocha (options) {
|
|
76
78
|
options = options || {};
|
|
77
79
|
this.files = [];
|
|
78
80
|
this.options = options;
|
|
@@ -107,7 +109,7 @@ function Mocha(options) {
|
|
|
107
109
|
* @api public
|
|
108
110
|
* @param {boolean} [bail]
|
|
109
111
|
*/
|
|
110
|
-
Mocha.prototype.bail = function(bail) {
|
|
112
|
+
Mocha.prototype.bail = function (bail) {
|
|
111
113
|
if (!arguments.length) {
|
|
112
114
|
bail = true;
|
|
113
115
|
}
|
|
@@ -121,7 +123,7 @@ Mocha.prototype.bail = function(bail) {
|
|
|
121
123
|
* @api public
|
|
122
124
|
* @param {string} file
|
|
123
125
|
*/
|
|
124
|
-
Mocha.prototype.addFile = function(file) {
|
|
126
|
+
Mocha.prototype.addFile = function (file) {
|
|
125
127
|
this.files.push(file);
|
|
126
128
|
return this;
|
|
127
129
|
};
|
|
@@ -135,7 +137,7 @@ Mocha.prototype.addFile = function(file) {
|
|
|
135
137
|
* @param {string|Function} reporter name or constructor
|
|
136
138
|
* @param {Object} reporterOptions optional options
|
|
137
139
|
*/
|
|
138
|
-
Mocha.prototype.reporter = function(reporter, reporterOptions) {
|
|
140
|
+
Mocha.prototype.reporter = function (reporter, reporterOptions) {
|
|
139
141
|
if (typeof reporter === 'function') {
|
|
140
142
|
this._reporter = reporter;
|
|
141
143
|
} else {
|
|
@@ -156,9 +158,9 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) {
|
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
160
|
if (!_reporter && reporter === 'teamcity') {
|
|
159
|
-
console.warn('The Teamcity reporter was moved to a package named '
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
console.warn('The Teamcity reporter was moved to a package named ' +
|
|
162
|
+
'mocha-teamcity-reporter ' +
|
|
163
|
+
'(https://npmjs.org/package/mocha-teamcity-reporter).');
|
|
162
164
|
}
|
|
163
165
|
if (!_reporter) {
|
|
164
166
|
throw new Error('invalid reporter "' + reporter + '"');
|
|
@@ -175,7 +177,7 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) {
|
|
|
175
177
|
* @api public
|
|
176
178
|
* @param {string} bdd
|
|
177
179
|
*/
|
|
178
|
-
Mocha.prototype.ui = function(name) {
|
|
180
|
+
Mocha.prototype.ui = function (name) {
|
|
179
181
|
name = name || 'bdd';
|
|
180
182
|
this._ui = exports.interfaces[name];
|
|
181
183
|
if (!this._ui) {
|
|
@@ -187,7 +189,7 @@ Mocha.prototype.ui = function(name) {
|
|
|
187
189
|
}
|
|
188
190
|
this._ui = this._ui(this.suite);
|
|
189
191
|
|
|
190
|
-
this.suite.on('pre-require', function(context) {
|
|
192
|
+
this.suite.on('pre-require', function (context) {
|
|
191
193
|
exports.afterEach = context.afterEach || context.teardown;
|
|
192
194
|
exports.after = context.after || context.suiteTeardown;
|
|
193
195
|
exports.beforeEach = context.beforeEach || context.setup;
|
|
@@ -211,10 +213,10 @@ Mocha.prototype.ui = function(name) {
|
|
|
211
213
|
*
|
|
212
214
|
* @api private
|
|
213
215
|
*/
|
|
214
|
-
Mocha.prototype.loadFiles = function(fn) {
|
|
216
|
+
Mocha.prototype.loadFiles = function (fn) {
|
|
215
217
|
var self = this;
|
|
216
218
|
var suite = this.suite;
|
|
217
|
-
this.files.forEach(function(file) {
|
|
219
|
+
this.files.forEach(function (file) {
|
|
218
220
|
file = path.resolve(file);
|
|
219
221
|
suite.emit('pre-require', global, file, self);
|
|
220
222
|
suite.emit('require', require(file), file, self);
|
|
@@ -228,10 +230,10 @@ Mocha.prototype.loadFiles = function(fn) {
|
|
|
228
230
|
*
|
|
229
231
|
* @api private
|
|
230
232
|
*/
|
|
231
|
-
Mocha.prototype._growl = function(runner, reporter) {
|
|
233
|
+
Mocha.prototype._growl = function (runner, reporter) {
|
|
232
234
|
var notify = require('growl');
|
|
233
235
|
|
|
234
|
-
runner.on('end', function() {
|
|
236
|
+
runner.on('end', function () {
|
|
235
237
|
var stats = reporter.stats;
|
|
236
238
|
if (stats.failures) {
|
|
237
239
|
var msg = stats.failures + ' of ' + runner.total + ' tests failed';
|
|
@@ -253,7 +255,7 @@ Mocha.prototype._growl = function(runner, reporter) {
|
|
|
253
255
|
* @param str
|
|
254
256
|
* @returns {Mocha}
|
|
255
257
|
*/
|
|
256
|
-
Mocha.prototype.fgrep = function(str) {
|
|
258
|
+
Mocha.prototype.fgrep = function (str) {
|
|
257
259
|
return this.grep(new RegExp(escapeRe(str)));
|
|
258
260
|
};
|
|
259
261
|
|
|
@@ -266,7 +268,7 @@ Mocha.prototype.fgrep = function(str) {
|
|
|
266
268
|
* @param {RegExp|string} re
|
|
267
269
|
* @return {Mocha}
|
|
268
270
|
*/
|
|
269
|
-
Mocha.prototype.grep = function(re) {
|
|
271
|
+
Mocha.prototype.grep = function (re) {
|
|
270
272
|
if (utils.isString(re)) {
|
|
271
273
|
// extract args if it's regex-like, i.e: [string, pattern, flag]
|
|
272
274
|
var arg = re.match(/^\/(.*)\/(g|i|)$|.*/);
|
|
@@ -282,7 +284,7 @@ Mocha.prototype.grep = function(re) {
|
|
|
282
284
|
* @return {Mocha}
|
|
283
285
|
* @api public
|
|
284
286
|
*/
|
|
285
|
-
Mocha.prototype.invert = function() {
|
|
287
|
+
Mocha.prototype.invert = function () {
|
|
286
288
|
this.options.invert = true;
|
|
287
289
|
return this;
|
|
288
290
|
};
|
|
@@ -296,7 +298,7 @@ Mocha.prototype.invert = function() {
|
|
|
296
298
|
* @param {boolean} ignore
|
|
297
299
|
* @return {Mocha}
|
|
298
300
|
*/
|
|
299
|
-
Mocha.prototype.ignoreLeaks = function(ignore) {
|
|
301
|
+
Mocha.prototype.ignoreLeaks = function (ignore) {
|
|
300
302
|
this.options.ignoreLeaks = Boolean(ignore);
|
|
301
303
|
return this;
|
|
302
304
|
};
|
|
@@ -307,7 +309,7 @@ Mocha.prototype.ignoreLeaks = function(ignore) {
|
|
|
307
309
|
* @return {Mocha}
|
|
308
310
|
* @api public
|
|
309
311
|
*/
|
|
310
|
-
Mocha.prototype.checkLeaks = function() {
|
|
312
|
+
Mocha.prototype.checkLeaks = function () {
|
|
311
313
|
this.options.ignoreLeaks = false;
|
|
312
314
|
return this;
|
|
313
315
|
};
|
|
@@ -318,7 +320,7 @@ Mocha.prototype.checkLeaks = function() {
|
|
|
318
320
|
* @return {Mocha}
|
|
319
321
|
* @api public
|
|
320
322
|
*/
|
|
321
|
-
Mocha.prototype.fullTrace = function() {
|
|
323
|
+
Mocha.prototype.fullTrace = function () {
|
|
322
324
|
this.options.fullStackTrace = true;
|
|
323
325
|
return this;
|
|
324
326
|
};
|
|
@@ -329,7 +331,7 @@ Mocha.prototype.fullTrace = function() {
|
|
|
329
331
|
* @return {Mocha}
|
|
330
332
|
* @api public
|
|
331
333
|
*/
|
|
332
|
-
Mocha.prototype.growl = function() {
|
|
334
|
+
Mocha.prototype.growl = function () {
|
|
333
335
|
this.options.growl = true;
|
|
334
336
|
return this;
|
|
335
337
|
};
|
|
@@ -343,7 +345,7 @@ Mocha.prototype.growl = function() {
|
|
|
343
345
|
* @param {Array|string} globals
|
|
344
346
|
* @return {Mocha}
|
|
345
347
|
*/
|
|
346
|
-
Mocha.prototype.globals = function(globals) {
|
|
348
|
+
Mocha.prototype.globals = function (globals) {
|
|
347
349
|
this.options.globals = (this.options.globals || []).concat(globals);
|
|
348
350
|
return this;
|
|
349
351
|
};
|
|
@@ -357,7 +359,7 @@ Mocha.prototype.globals = function(globals) {
|
|
|
357
359
|
* @param {boolean} colors
|
|
358
360
|
* @return {Mocha}
|
|
359
361
|
*/
|
|
360
|
-
Mocha.prototype.useColors = function(colors) {
|
|
362
|
+
Mocha.prototype.useColors = function (colors) {
|
|
361
363
|
if (colors !== undefined) {
|
|
362
364
|
this.options.useColors = colors;
|
|
363
365
|
}
|
|
@@ -373,7 +375,7 @@ Mocha.prototype.useColors = function(colors) {
|
|
|
373
375
|
* @param {boolean} inlineDiffs
|
|
374
376
|
* @return {Mocha}
|
|
375
377
|
*/
|
|
376
|
-
Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
|
|
378
|
+
Mocha.prototype.useInlineDiffs = function (inlineDiffs) {
|
|
377
379
|
this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs;
|
|
378
380
|
return this;
|
|
379
381
|
};
|
|
@@ -387,7 +389,7 @@ Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
|
|
|
387
389
|
* @param {number} timeout
|
|
388
390
|
* @return {Mocha}
|
|
389
391
|
*/
|
|
390
|
-
Mocha.prototype.timeout = function(timeout) {
|
|
392
|
+
Mocha.prototype.timeout = function (timeout) {
|
|
391
393
|
this.suite.timeout(timeout);
|
|
392
394
|
return this;
|
|
393
395
|
};
|
|
@@ -399,7 +401,7 @@ Mocha.prototype.timeout = function(timeout) {
|
|
|
399
401
|
* @return {Mocha}
|
|
400
402
|
* @api public
|
|
401
403
|
*/
|
|
402
|
-
Mocha.prototype.retries = function(n) {
|
|
404
|
+
Mocha.prototype.retries = function (n) {
|
|
403
405
|
this.suite.retries(n);
|
|
404
406
|
return this;
|
|
405
407
|
};
|
|
@@ -413,7 +415,7 @@ Mocha.prototype.retries = function(n) {
|
|
|
413
415
|
* @param {number} slow
|
|
414
416
|
* @return {Mocha}
|
|
415
417
|
*/
|
|
416
|
-
Mocha.prototype.slow = function(slow) {
|
|
418
|
+
Mocha.prototype.slow = function (slow) {
|
|
417
419
|
this.suite.slow(slow);
|
|
418
420
|
return this;
|
|
419
421
|
};
|
|
@@ -427,7 +429,7 @@ Mocha.prototype.slow = function(slow) {
|
|
|
427
429
|
* @param {boolean} enabled
|
|
428
430
|
* @return {Mocha}
|
|
429
431
|
*/
|
|
430
|
-
Mocha.prototype.enableTimeouts = function(enabled) {
|
|
432
|
+
Mocha.prototype.enableTimeouts = function (enabled) {
|
|
431
433
|
this.suite.enableTimeouts(arguments.length && enabled !== undefined ? enabled : true);
|
|
432
434
|
return this;
|
|
433
435
|
};
|
|
@@ -438,7 +440,7 @@ Mocha.prototype.enableTimeouts = function(enabled) {
|
|
|
438
440
|
* @return {Mocha}
|
|
439
441
|
* @api public
|
|
440
442
|
*/
|
|
441
|
-
Mocha.prototype.asyncOnly = function() {
|
|
443
|
+
Mocha.prototype.asyncOnly = function () {
|
|
442
444
|
this.options.asyncOnly = true;
|
|
443
445
|
return this;
|
|
444
446
|
};
|
|
@@ -448,7 +450,7 @@ Mocha.prototype.asyncOnly = function() {
|
|
|
448
450
|
*
|
|
449
451
|
* @api public
|
|
450
452
|
*/
|
|
451
|
-
Mocha.prototype.noHighlighting = function() {
|
|
453
|
+
Mocha.prototype.noHighlighting = function () {
|
|
452
454
|
this.options.noHighlighting = true;
|
|
453
455
|
return this;
|
|
454
456
|
};
|
|
@@ -459,7 +461,7 @@ Mocha.prototype.noHighlighting = function() {
|
|
|
459
461
|
* @return {Mocha}
|
|
460
462
|
* @api public
|
|
461
463
|
*/
|
|
462
|
-
Mocha.prototype.allowUncaught = function() {
|
|
464
|
+
Mocha.prototype.allowUncaught = function () {
|
|
463
465
|
this.options.allowUncaught = true;
|
|
464
466
|
return this;
|
|
465
467
|
};
|
|
@@ -468,7 +470,7 @@ Mocha.prototype.allowUncaught = function() {
|
|
|
468
470
|
* Delay root suite execution.
|
|
469
471
|
* @returns {Mocha}
|
|
470
472
|
*/
|
|
471
|
-
Mocha.prototype.delay = function delay() {
|
|
473
|
+
Mocha.prototype.delay = function delay () {
|
|
472
474
|
this.options.delay = true;
|
|
473
475
|
return this;
|
|
474
476
|
};
|
|
@@ -480,7 +482,7 @@ Mocha.prototype.delay = function delay() {
|
|
|
480
482
|
* @param {Function} fn
|
|
481
483
|
* @return {Runner}
|
|
482
484
|
*/
|
|
483
|
-
Mocha.prototype.run = function(fn) {
|
|
485
|
+
Mocha.prototype.run = function (fn) {
|
|
484
486
|
if (this.files.length) {
|
|
485
487
|
this.loadFiles();
|
|
486
488
|
}
|
|
@@ -508,7 +510,7 @@ Mocha.prototype.run = function(fn) {
|
|
|
508
510
|
}
|
|
509
511
|
exports.reporters.Base.inlineDiffs = options.useInlineDiffs;
|
|
510
512
|
|
|
511
|
-
function done(failures) {
|
|
513
|
+
function done (failures) {
|
|
512
514
|
if (reporter.done) {
|
|
513
515
|
reporter.done(failures, fn);
|
|
514
516
|
} else {
|
package/lib/ms.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Helpers.
|
|
3
5
|
*/
|
|
@@ -20,7 +22,7 @@ var y = d * 365.25;
|
|
|
20
22
|
* @param {Object} options
|
|
21
23
|
* @return {string|number}
|
|
22
24
|
*/
|
|
23
|
-
module.exports = function(val, options) {
|
|
25
|
+
module.exports = function (val, options) {
|
|
24
26
|
options = options || {};
|
|
25
27
|
if (typeof val === 'string') {
|
|
26
28
|
return parse(val);
|
|
@@ -36,7 +38,7 @@ module.exports = function(val, options) {
|
|
|
36
38
|
* @param {string} str
|
|
37
39
|
* @return {number}
|
|
38
40
|
*/
|
|
39
|
-
function parse(str) {
|
|
41
|
+
function parse (str) {
|
|
40
42
|
var match = (/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i).exec(str);
|
|
41
43
|
if (!match) {
|
|
42
44
|
return;
|
|
@@ -78,7 +80,7 @@ function parse(str) {
|
|
|
78
80
|
* @param {number} ms
|
|
79
81
|
* @return {string}
|
|
80
82
|
*/
|
|
81
|
-
function shortFormat(ms) {
|
|
83
|
+
function shortFormat (ms) {
|
|
82
84
|
if (ms >= d) {
|
|
83
85
|
return Math.round(ms / d) + 'd';
|
|
84
86
|
}
|
|
@@ -101,12 +103,12 @@ function shortFormat(ms) {
|
|
|
101
103
|
* @param {number} ms
|
|
102
104
|
* @return {string}
|
|
103
105
|
*/
|
|
104
|
-
function longFormat(ms) {
|
|
105
|
-
return plural(ms, d, 'day')
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
function longFormat (ms) {
|
|
107
|
+
return plural(ms, d, 'day') ||
|
|
108
|
+
plural(ms, h, 'hour') ||
|
|
109
|
+
plural(ms, m, 'minute') ||
|
|
110
|
+
plural(ms, s, 'second') ||
|
|
111
|
+
ms + ' ms';
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
/**
|
|
@@ -117,7 +119,7 @@ function longFormat(ms) {
|
|
|
117
119
|
* @param {number} n
|
|
118
120
|
* @param {string} name
|
|
119
121
|
*/
|
|
120
|
-
function plural(ms, n, name) {
|
|
122
|
+
function plural (ms, n, name) {
|
|
121
123
|
if (ms < n) {
|
|
122
124
|
return;
|
|
123
125
|
}
|