mocha 5.1.1 → 5.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 +32 -0
- package/bin/_mocha +82 -36
- package/bin/options.js +14 -8
- package/browser-entry.js +20 -16
- package/lib/browser/progress.js +8 -8
- package/lib/browser/tty.js +2 -2
- package/lib/context.js +7 -7
- package/lib/hook.js +5 -16
- package/lib/interfaces/bdd.js +12 -13
- package/lib/interfaces/common.js +18 -15
- package/lib/interfaces/exports.js +2 -7
- package/lib/interfaces/qunit.js +6 -10
- package/lib/interfaces/tdd.js +7 -11
- package/lib/mocha.js +56 -57
- package/lib/ms.js +7 -5
- package/lib/pending.js +1 -5
- package/lib/reporters/base.js +91 -63
- package/lib/reporters/doc.js +16 -8
- package/lib/reporters/dot.js +7 -7
- package/lib/reporters/html.js +74 -40
- package/lib/reporters/json-stream.js +7 -7
- package/lib/reporters/json.js +21 -19
- package/lib/reporters/landing.js +7 -7
- package/lib/reporters/list.js +9 -9
- package/lib/reporters/markdown.js +11 -11
- package/lib/reporters/min.js +2 -2
- package/lib/reporters/nyan.js +24 -24
- package/lib/reporters/progress.js +6 -6
- package/lib/reporters/spec.js +12 -10
- package/lib/reporters/tap.js +8 -8
- package/lib/reporters/xunit.js +41 -23
- package/lib/runnable.js +64 -62
- package/lib/runner.js +99 -78
- package/lib/suite.js +39 -33
- package/lib/test.js +9 -13
- package/lib/utils.js +131 -85
- package/mocha.js +1556 -1064
- package/package.json +32 -19
- package/images/error.png +0 -0
- package/images/ok.png +0 -0
package/lib/interfaces/common.js
CHANGED
|
@@ -10,7 +10,7 @@ var Suite = require('../suite');
|
|
|
10
10
|
* @param {Mocha} mocha
|
|
11
11
|
* @return {Object} An object containing common functions.
|
|
12
12
|
*/
|
|
13
|
-
module.exports = function
|
|
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
|
|
@@ -19,8 +19,8 @@ module.exports = function (suites, context, mocha) {
|
|
|
19
19
|
* @param {Suite} suite The root suite.
|
|
20
20
|
* @return {Function} A function which runs the root suite
|
|
21
21
|
*/
|
|
22
|
-
runWithSuite: function runWithSuite
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
76
|
+
only: function only(opts) {
|
|
77
77
|
opts.isOnly = true;
|
|
78
78
|
return this.create(opts);
|
|
79
79
|
},
|
|
@@ -85,7 +85,7 @@ module.exports = function (suites, context, mocha) {
|
|
|
85
85
|
* @param {Object} opts
|
|
86
86
|
* @returns {Suite}
|
|
87
87
|
*/
|
|
88
|
-
skip: function skip
|
|
88
|
+
skip: function skip(opts) {
|
|
89
89
|
opts.pending = true;
|
|
90
90
|
return this.create(opts);
|
|
91
91
|
},
|
|
@@ -100,7 +100,7 @@ module.exports = function (suites, context, mocha) {
|
|
|
100
100
|
* @param {boolean} [opts.isOnly] Is Suite exclusive?
|
|
101
101
|
* @returns {Suite}
|
|
102
102
|
*/
|
|
103
|
-
create: function create
|
|
103
|
+
create: function create(opts) {
|
|
104
104
|
var suite = Suite.create(suites[0], opts.title);
|
|
105
105
|
suite.pending = Boolean(opts.pending);
|
|
106
106
|
suite.file = opts.file;
|
|
@@ -112,7 +112,11 @@ module.exports = function (suites, context, mocha) {
|
|
|
112
112
|
opts.fn.call(suite);
|
|
113
113
|
suites.shift();
|
|
114
114
|
} else if (typeof opts.fn === 'undefined' && !suite.pending) {
|
|
115
|
-
throw new Error(
|
|
115
|
+
throw new Error(
|
|
116
|
+
'Suite "' +
|
|
117
|
+
suite.fullTitle() +
|
|
118
|
+
'" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.'
|
|
119
|
+
);
|
|
116
120
|
} else if (!opts.fn && suite.pending) {
|
|
117
121
|
suites.shift();
|
|
118
122
|
}
|
|
@@ -122,7 +126,6 @@ module.exports = function (suites, context, mocha) {
|
|
|
122
126
|
},
|
|
123
127
|
|
|
124
128
|
test: {
|
|
125
|
-
|
|
126
129
|
/**
|
|
127
130
|
* Exclusive test-case.
|
|
128
131
|
*
|
|
@@ -130,7 +133,7 @@ module.exports = function (suites, context, mocha) {
|
|
|
130
133
|
* @param {Function} test
|
|
131
134
|
* @returns {*}
|
|
132
135
|
*/
|
|
133
|
-
only: function
|
|
136
|
+
only: function(mocha, test) {
|
|
134
137
|
test.parent._onlyTests = test.parent._onlyTests.concat(test);
|
|
135
138
|
return test;
|
|
136
139
|
},
|
|
@@ -140,7 +143,7 @@ module.exports = function (suites, context, mocha) {
|
|
|
140
143
|
*
|
|
141
144
|
* @param {string} title
|
|
142
145
|
*/
|
|
143
|
-
skip: function
|
|
146
|
+
skip: function(title) {
|
|
144
147
|
context.test(title);
|
|
145
148
|
},
|
|
146
149
|
|
|
@@ -149,7 +152,7 @@ module.exports = function (suites, context, mocha) {
|
|
|
149
152
|
*
|
|
150
153
|
* @param {number} n
|
|
151
154
|
*/
|
|
152
|
-
retries: function
|
|
155
|
+
retries: function(n) {
|
|
153
156
|
context.retries(n);
|
|
154
157
|
}
|
|
155
158
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Module dependencies.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
2
|
var Suite = require('../suite');
|
|
8
3
|
var Test = require('../test');
|
|
9
4
|
|
|
@@ -24,12 +19,12 @@ var Test = require('../test');
|
|
|
24
19
|
*
|
|
25
20
|
* @param {Suite} suite Root suite.
|
|
26
21
|
*/
|
|
27
|
-
module.exports = function
|
|
22
|
+
module.exports = function(suite) {
|
|
28
23
|
var suites = [suite];
|
|
29
24
|
|
|
30
25
|
suite.on('require', visit);
|
|
31
26
|
|
|
32
|
-
function visit
|
|
27
|
+
function visit(obj, file) {
|
|
33
28
|
var suite;
|
|
34
29
|
for (var key in obj) {
|
|
35
30
|
if (typeof obj[key] === 'function') {
|
package/lib/interfaces/qunit.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Module dependencies.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
3
|
var Test = require('../test');
|
|
8
4
|
|
|
9
5
|
/**
|
|
@@ -31,10 +27,10 @@ var Test = require('../test');
|
|
|
31
27
|
*
|
|
32
28
|
* @param {Suite} suite Root suite.
|
|
33
29
|
*/
|
|
34
|
-
module.exports = function (suite) {
|
|
30
|
+
module.exports = function qUnitInterface(suite) {
|
|
35
31
|
var suites = [suite];
|
|
36
32
|
|
|
37
|
-
suite.on('pre-require', function
|
|
33
|
+
suite.on('pre-require', function(context, file, mocha) {
|
|
38
34
|
var common = require('./common')(suites, context, mocha);
|
|
39
35
|
|
|
40
36
|
context.before = common.before;
|
|
@@ -46,7 +42,7 @@ module.exports = function (suite) {
|
|
|
46
42
|
* Describe a "suite" with the given `title`.
|
|
47
43
|
*/
|
|
48
44
|
|
|
49
|
-
context.suite = function
|
|
45
|
+
context.suite = function(title) {
|
|
50
46
|
if (suites.length > 1) {
|
|
51
47
|
suites.shift();
|
|
52
48
|
}
|
|
@@ -61,7 +57,7 @@ module.exports = function (suite) {
|
|
|
61
57
|
* Exclusive Suite.
|
|
62
58
|
*/
|
|
63
59
|
|
|
64
|
-
context.suite.only = function
|
|
60
|
+
context.suite.only = function(title) {
|
|
65
61
|
if (suites.length > 1) {
|
|
66
62
|
suites.shift();
|
|
67
63
|
}
|
|
@@ -78,7 +74,7 @@ module.exports = function (suite) {
|
|
|
78
74
|
* acting as a thunk.
|
|
79
75
|
*/
|
|
80
76
|
|
|
81
|
-
context.test = function
|
|
77
|
+
context.test = function(title, fn) {
|
|
82
78
|
var test = new Test(title, fn);
|
|
83
79
|
test.file = file;
|
|
84
80
|
suites[0].addTest(test);
|
|
@@ -89,7 +85,7 @@ module.exports = function (suite) {
|
|
|
89
85
|
* Exclusive test-case.
|
|
90
86
|
*/
|
|
91
87
|
|
|
92
|
-
context.test.only = function
|
|
88
|
+
context.test.only = function(title, fn) {
|
|
93
89
|
return common.test.only(mocha, context.test(title, fn));
|
|
94
90
|
};
|
|
95
91
|
|
package/lib/interfaces/tdd.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Module dependencies.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
3
|
var Test = require('../test');
|
|
8
4
|
|
|
9
5
|
/**
|
|
@@ -31,10 +27,10 @@ var Test = require('../test');
|
|
|
31
27
|
*
|
|
32
28
|
* @param {Suite} suite Root suite.
|
|
33
29
|
*/
|
|
34
|
-
module.exports = function
|
|
30
|
+
module.exports = function(suite) {
|
|
35
31
|
var suites = [suite];
|
|
36
32
|
|
|
37
|
-
suite.on('pre-require', function
|
|
33
|
+
suite.on('pre-require', function(context, file, mocha) {
|
|
38
34
|
var common = require('./common')(suites, context, mocha);
|
|
39
35
|
|
|
40
36
|
context.setup = common.beforeEach;
|
|
@@ -47,7 +43,7 @@ module.exports = function (suite) {
|
|
|
47
43
|
* Describe a "suite" with the given `title` and callback `fn` containing
|
|
48
44
|
* nested suites and/or tests.
|
|
49
45
|
*/
|
|
50
|
-
context.suite = function
|
|
46
|
+
context.suite = function(title, fn) {
|
|
51
47
|
return common.suite.create({
|
|
52
48
|
title: title,
|
|
53
49
|
file: file,
|
|
@@ -58,7 +54,7 @@ module.exports = function (suite) {
|
|
|
58
54
|
/**
|
|
59
55
|
* Pending suite.
|
|
60
56
|
*/
|
|
61
|
-
context.suite.skip = function
|
|
57
|
+
context.suite.skip = function(title, fn) {
|
|
62
58
|
return common.suite.skip({
|
|
63
59
|
title: title,
|
|
64
60
|
file: file,
|
|
@@ -69,7 +65,7 @@ module.exports = function (suite) {
|
|
|
69
65
|
/**
|
|
70
66
|
* Exclusive test-case.
|
|
71
67
|
*/
|
|
72
|
-
context.suite.only = function
|
|
68
|
+
context.suite.only = function(title, fn) {
|
|
73
69
|
return common.suite.only({
|
|
74
70
|
title: title,
|
|
75
71
|
file: file,
|
|
@@ -81,7 +77,7 @@ module.exports = function (suite) {
|
|
|
81
77
|
* Describe a specification or test-case with the given `title` and
|
|
82
78
|
* callback `fn` acting as a thunk.
|
|
83
79
|
*/
|
|
84
|
-
context.test = function
|
|
80
|
+
context.test = function(title, fn) {
|
|
85
81
|
var suite = suites[0];
|
|
86
82
|
if (suite.isPending()) {
|
|
87
83
|
fn = null;
|
|
@@ -96,7 +92,7 @@ module.exports = function (suite) {
|
|
|
96
92
|
* Exclusive test-case.
|
|
97
93
|
*/
|
|
98
94
|
|
|
99
|
-
context.test.only = function
|
|
95
|
+
context.test.only = function(title, fn) {
|
|
100
96
|
return common.test.only(mocha, context.test(title, fn));
|
|
101
97
|
};
|
|
102
98
|
|
package/lib/mocha.js
CHANGED
|
@@ -5,23 +5,12 @@
|
|
|
5
5
|
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
|
|
6
6
|
* MIT Licensed
|
|
7
7
|
*/
|
|
8
|
-
/**
|
|
9
|
-
* @namespace Mocha
|
|
10
|
-
* @module Mocha
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Module dependencies.
|
|
14
|
-
*/
|
|
15
8
|
|
|
16
9
|
var escapeRe = require('escape-string-regexp');
|
|
17
10
|
var path = require('path');
|
|
18
11
|
var reporters = require('./reporters');
|
|
19
12
|
var utils = require('./utils');
|
|
20
13
|
|
|
21
|
-
/**
|
|
22
|
-
* Expose `Mocha`.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
14
|
exports = module.exports = Mocha;
|
|
26
15
|
|
|
27
16
|
/**
|
|
@@ -64,12 +53,12 @@ exports.Test = require('./test');
|
|
|
64
53
|
/**
|
|
65
54
|
* Return image `name` path.
|
|
66
55
|
*
|
|
67
|
-
* @
|
|
56
|
+
* @private
|
|
68
57
|
* @param {string} name
|
|
69
58
|
* @return {string}
|
|
70
59
|
*/
|
|
71
|
-
function image
|
|
72
|
-
return path.join(__dirname, '
|
|
60
|
+
function image(name) {
|
|
61
|
+
return path.join(__dirname, '..', 'assets', 'growl', name + '.png');
|
|
73
62
|
}
|
|
74
63
|
|
|
75
64
|
/**
|
|
@@ -88,12 +77,10 @@ function image (name) {
|
|
|
88
77
|
* - `fullTrace` display the full stack-trace on failing
|
|
89
78
|
* - `grep` string or regexp to filter tests with
|
|
90
79
|
*
|
|
91
|
-
* @public
|
|
92
80
|
* @class Mocha
|
|
93
81
|
* @param {Object} options
|
|
94
|
-
* @api public
|
|
95
82
|
*/
|
|
96
|
-
function Mocha
|
|
83
|
+
function Mocha(options) {
|
|
97
84
|
options = options || {};
|
|
98
85
|
this.files = [];
|
|
99
86
|
this.options = options;
|
|
@@ -129,7 +116,7 @@ function Mocha (options) {
|
|
|
129
116
|
* @api public
|
|
130
117
|
* @param {boolean} [bail]
|
|
131
118
|
*/
|
|
132
|
-
Mocha.prototype.bail = function
|
|
119
|
+
Mocha.prototype.bail = function(bail) {
|
|
133
120
|
if (!arguments.length) {
|
|
134
121
|
bail = true;
|
|
135
122
|
}
|
|
@@ -144,7 +131,7 @@ Mocha.prototype.bail = function (bail) {
|
|
|
144
131
|
* @api public
|
|
145
132
|
* @param {string} file
|
|
146
133
|
*/
|
|
147
|
-
Mocha.prototype.addFile = function
|
|
134
|
+
Mocha.prototype.addFile = function(file) {
|
|
148
135
|
this.files.push(file);
|
|
149
136
|
return this;
|
|
150
137
|
};
|
|
@@ -159,7 +146,7 @@ Mocha.prototype.addFile = function (file) {
|
|
|
159
146
|
* @param {string|Function} reporter name or constructor
|
|
160
147
|
* @param {Object} reporterOptions optional options
|
|
161
148
|
*/
|
|
162
|
-
Mocha.prototype.reporter = function
|
|
149
|
+
Mocha.prototype.reporter = function(reporter, reporterOptions) {
|
|
163
150
|
if (typeof reporter === 'function') {
|
|
164
151
|
this._reporter = reporter;
|
|
165
152
|
} else {
|
|
@@ -179,18 +166,28 @@ Mocha.prototype.reporter = function (reporter, reporterOptions) {
|
|
|
179
166
|
try {
|
|
180
167
|
_reporter = require(path.resolve(process.cwd(), reporter));
|
|
181
168
|
} catch (_err) {
|
|
182
|
-
err.message.indexOf('Cannot find module') !== -1
|
|
183
|
-
|
|
169
|
+
err.message.indexOf('Cannot find module') !== -1
|
|
170
|
+
? console.warn('"' + reporter + '" reporter not found')
|
|
171
|
+
: console.warn(
|
|
172
|
+
'"' +
|
|
173
|
+
reporter +
|
|
174
|
+
'" reporter blew up with error:\n' +
|
|
175
|
+
err.stack
|
|
176
|
+
);
|
|
184
177
|
}
|
|
185
178
|
} else {
|
|
186
|
-
console.warn(
|
|
179
|
+
console.warn(
|
|
180
|
+
'"' + reporter + '" reporter blew up with error:\n' + err.stack
|
|
181
|
+
);
|
|
187
182
|
}
|
|
188
183
|
}
|
|
189
184
|
}
|
|
190
185
|
if (!_reporter && reporter === 'teamcity') {
|
|
191
|
-
console.warn(
|
|
192
|
-
'
|
|
193
|
-
|
|
186
|
+
console.warn(
|
|
187
|
+
'The Teamcity reporter was moved to a package named ' +
|
|
188
|
+
'mocha-teamcity-reporter ' +
|
|
189
|
+
'(https://npmjs.org/package/mocha-teamcity-reporter).'
|
|
190
|
+
);
|
|
194
191
|
}
|
|
195
192
|
if (!_reporter) {
|
|
196
193
|
throw new Error('invalid reporter "' + reporter + '"');
|
|
@@ -207,7 +204,7 @@ Mocha.prototype.reporter = function (reporter, reporterOptions) {
|
|
|
207
204
|
* @api public
|
|
208
205
|
* @param {string} bdd
|
|
209
206
|
*/
|
|
210
|
-
Mocha.prototype.ui = function
|
|
207
|
+
Mocha.prototype.ui = function(name) {
|
|
211
208
|
name = name || 'bdd';
|
|
212
209
|
this._ui = exports.interfaces[name];
|
|
213
210
|
if (!this._ui) {
|
|
@@ -219,7 +216,7 @@ Mocha.prototype.ui = function (name) {
|
|
|
219
216
|
}
|
|
220
217
|
this._ui = this._ui(this.suite);
|
|
221
218
|
|
|
222
|
-
this.suite.on('pre-require', function
|
|
219
|
+
this.suite.on('pre-require', function(context) {
|
|
223
220
|
exports.afterEach = context.afterEach || context.teardown;
|
|
224
221
|
exports.after = context.after || context.suiteTeardown;
|
|
225
222
|
exports.beforeEach = context.beforeEach || context.setup;
|
|
@@ -244,10 +241,10 @@ Mocha.prototype.ui = function (name) {
|
|
|
244
241
|
*
|
|
245
242
|
* @api private
|
|
246
243
|
*/
|
|
247
|
-
Mocha.prototype.loadFiles = function
|
|
244
|
+
Mocha.prototype.loadFiles = function(fn) {
|
|
248
245
|
var self = this;
|
|
249
246
|
var suite = this.suite;
|
|
250
|
-
this.files.forEach(function
|
|
247
|
+
this.files.forEach(function(file) {
|
|
251
248
|
file = path.resolve(file);
|
|
252
249
|
suite.emit('pre-require', global, file, self);
|
|
253
250
|
suite.emit('require', require(file), file, self);
|
|
@@ -261,14 +258,14 @@ Mocha.prototype.loadFiles = function (fn) {
|
|
|
261
258
|
*
|
|
262
259
|
* @api private
|
|
263
260
|
*/
|
|
264
|
-
Mocha.prototype._growl = function
|
|
261
|
+
Mocha.prototype._growl = function(runner, reporter) {
|
|
265
262
|
var notify = require('growl');
|
|
266
263
|
|
|
267
|
-
runner.on('end', function
|
|
264
|
+
runner.on('end', function() {
|
|
268
265
|
var stats = reporter.stats;
|
|
269
266
|
if (stats.failures) {
|
|
270
267
|
var msg = stats.failures + ' of ' + runner.total + ' tests failed';
|
|
271
|
-
notify(msg, {
|
|
268
|
+
notify(msg, {name: 'mocha', title: 'Failed', image: image('error')});
|
|
272
269
|
} else {
|
|
273
270
|
notify(stats.passes + ' tests passed in ' + stats.duration + 'ms', {
|
|
274
271
|
name: 'mocha',
|
|
@@ -287,7 +284,7 @@ Mocha.prototype._growl = function (runner, reporter) {
|
|
|
287
284
|
* @param str
|
|
288
285
|
* @returns {Mocha}
|
|
289
286
|
*/
|
|
290
|
-
Mocha.prototype.fgrep = function
|
|
287
|
+
Mocha.prototype.fgrep = function(str) {
|
|
291
288
|
return this.grep(new RegExp(escapeRe(str)));
|
|
292
289
|
};
|
|
293
290
|
|
|
@@ -301,7 +298,7 @@ Mocha.prototype.fgrep = function (str) {
|
|
|
301
298
|
* @param {RegExp|string} re
|
|
302
299
|
* @return {Mocha}
|
|
303
300
|
*/
|
|
304
|
-
Mocha.prototype.grep = function
|
|
301
|
+
Mocha.prototype.grep = function(re) {
|
|
305
302
|
if (utils.isString(re)) {
|
|
306
303
|
// extract args if it's regex-like, i.e: [string, pattern, flag]
|
|
307
304
|
var arg = re.match(/^\/(.*)\/(g|i|)$|.*/);
|
|
@@ -318,7 +315,7 @@ Mocha.prototype.grep = function (re) {
|
|
|
318
315
|
* @return {Mocha}
|
|
319
316
|
* @api public
|
|
320
317
|
*/
|
|
321
|
-
Mocha.prototype.invert = function
|
|
318
|
+
Mocha.prototype.invert = function() {
|
|
322
319
|
this.options.invert = true;
|
|
323
320
|
return this;
|
|
324
321
|
};
|
|
@@ -333,7 +330,7 @@ Mocha.prototype.invert = function () {
|
|
|
333
330
|
* @param {boolean} ignore
|
|
334
331
|
* @return {Mocha}
|
|
335
332
|
*/
|
|
336
|
-
Mocha.prototype.ignoreLeaks = function
|
|
333
|
+
Mocha.prototype.ignoreLeaks = function(ignore) {
|
|
337
334
|
this.options.ignoreLeaks = Boolean(ignore);
|
|
338
335
|
return this;
|
|
339
336
|
};
|
|
@@ -345,7 +342,7 @@ Mocha.prototype.ignoreLeaks = function (ignore) {
|
|
|
345
342
|
* @api public
|
|
346
343
|
* @public
|
|
347
344
|
*/
|
|
348
|
-
Mocha.prototype.checkLeaks = function
|
|
345
|
+
Mocha.prototype.checkLeaks = function() {
|
|
349
346
|
this.options.ignoreLeaks = false;
|
|
350
347
|
return this;
|
|
351
348
|
};
|
|
@@ -357,7 +354,7 @@ Mocha.prototype.checkLeaks = function () {
|
|
|
357
354
|
* @api public
|
|
358
355
|
* @public
|
|
359
356
|
*/
|
|
360
|
-
Mocha.prototype.fullTrace = function
|
|
357
|
+
Mocha.prototype.fullTrace = function() {
|
|
361
358
|
this.options.fullStackTrace = true;
|
|
362
359
|
return this;
|
|
363
360
|
};
|
|
@@ -369,7 +366,7 @@ Mocha.prototype.fullTrace = function () {
|
|
|
369
366
|
* @api public
|
|
370
367
|
* @public
|
|
371
368
|
*/
|
|
372
|
-
Mocha.prototype.growl = function
|
|
369
|
+
Mocha.prototype.growl = function() {
|
|
373
370
|
this.options.growl = true;
|
|
374
371
|
return this;
|
|
375
372
|
};
|
|
@@ -384,7 +381,7 @@ Mocha.prototype.growl = function () {
|
|
|
384
381
|
* @param {Array|string} globals
|
|
385
382
|
* @return {Mocha}
|
|
386
383
|
*/
|
|
387
|
-
Mocha.prototype.globals = function
|
|
384
|
+
Mocha.prototype.globals = function(globals) {
|
|
388
385
|
this.options.globals = (this.options.globals || []).concat(globals);
|
|
389
386
|
return this;
|
|
390
387
|
};
|
|
@@ -399,7 +396,7 @@ Mocha.prototype.globals = function (globals) {
|
|
|
399
396
|
* @param {boolean} colors
|
|
400
397
|
* @return {Mocha}
|
|
401
398
|
*/
|
|
402
|
-
Mocha.prototype.useColors = function
|
|
399
|
+
Mocha.prototype.useColors = function(colors) {
|
|
403
400
|
if (colors !== undefined) {
|
|
404
401
|
this.options.useColors = colors;
|
|
405
402
|
}
|
|
@@ -416,7 +413,7 @@ Mocha.prototype.useColors = function (colors) {
|
|
|
416
413
|
* @param {boolean} inlineDiffs
|
|
417
414
|
* @return {Mocha}
|
|
418
415
|
*/
|
|
419
|
-
Mocha.prototype.useInlineDiffs = function
|
|
416
|
+
Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
|
|
420
417
|
this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs;
|
|
421
418
|
return this;
|
|
422
419
|
};
|
|
@@ -431,7 +428,7 @@ Mocha.prototype.useInlineDiffs = function (inlineDiffs) {
|
|
|
431
428
|
* @param {boolean} hideDiff
|
|
432
429
|
* @return {Mocha}
|
|
433
430
|
*/
|
|
434
|
-
Mocha.prototype.hideDiff = function
|
|
431
|
+
Mocha.prototype.hideDiff = function(hideDiff) {
|
|
435
432
|
this.options.hideDiff = hideDiff !== undefined && hideDiff;
|
|
436
433
|
return this;
|
|
437
434
|
};
|
|
@@ -446,7 +443,7 @@ Mocha.prototype.hideDiff = function (hideDiff) {
|
|
|
446
443
|
* @param {number} timeout
|
|
447
444
|
* @return {Mocha}
|
|
448
445
|
*/
|
|
449
|
-
Mocha.prototype.timeout = function
|
|
446
|
+
Mocha.prototype.timeout = function(timeout) {
|
|
450
447
|
this.suite.timeout(timeout);
|
|
451
448
|
return this;
|
|
452
449
|
};
|
|
@@ -459,7 +456,7 @@ Mocha.prototype.timeout = function (timeout) {
|
|
|
459
456
|
* @api public
|
|
460
457
|
* @public
|
|
461
458
|
*/
|
|
462
|
-
Mocha.prototype.retries = function
|
|
459
|
+
Mocha.prototype.retries = function(n) {
|
|
463
460
|
this.suite.retries(n);
|
|
464
461
|
return this;
|
|
465
462
|
};
|
|
@@ -474,7 +471,7 @@ Mocha.prototype.retries = function (n) {
|
|
|
474
471
|
* @param {number} slow
|
|
475
472
|
* @return {Mocha}
|
|
476
473
|
*/
|
|
477
|
-
Mocha.prototype.slow = function
|
|
474
|
+
Mocha.prototype.slow = function(slow) {
|
|
478
475
|
this.suite.slow(slow);
|
|
479
476
|
return this;
|
|
480
477
|
};
|
|
@@ -489,8 +486,10 @@ Mocha.prototype.slow = function (slow) {
|
|
|
489
486
|
* @param {boolean} enabled
|
|
490
487
|
* @return {Mocha}
|
|
491
488
|
*/
|
|
492
|
-
Mocha.prototype.enableTimeouts = function
|
|
493
|
-
this.suite.enableTimeouts(
|
|
489
|
+
Mocha.prototype.enableTimeouts = function(enabled) {
|
|
490
|
+
this.suite.enableTimeouts(
|
|
491
|
+
arguments.length && enabled !== undefined ? enabled : true
|
|
492
|
+
);
|
|
494
493
|
return this;
|
|
495
494
|
};
|
|
496
495
|
|
|
@@ -501,7 +500,7 @@ Mocha.prototype.enableTimeouts = function (enabled) {
|
|
|
501
500
|
* @api public
|
|
502
501
|
* @public
|
|
503
502
|
*/
|
|
504
|
-
Mocha.prototype.asyncOnly = function
|
|
503
|
+
Mocha.prototype.asyncOnly = function() {
|
|
505
504
|
this.options.asyncOnly = true;
|
|
506
505
|
return this;
|
|
507
506
|
};
|
|
@@ -512,7 +511,7 @@ Mocha.prototype.asyncOnly = function () {
|
|
|
512
511
|
* @api public
|
|
513
512
|
* @public
|
|
514
513
|
*/
|
|
515
|
-
Mocha.prototype.noHighlighting = function
|
|
514
|
+
Mocha.prototype.noHighlighting = function() {
|
|
516
515
|
this.options.noHighlighting = true;
|
|
517
516
|
return this;
|
|
518
517
|
};
|
|
@@ -524,7 +523,7 @@ Mocha.prototype.noHighlighting = function () {
|
|
|
524
523
|
* @api public
|
|
525
524
|
* @public
|
|
526
525
|
*/
|
|
527
|
-
Mocha.prototype.allowUncaught = function
|
|
526
|
+
Mocha.prototype.allowUncaught = function() {
|
|
528
527
|
this.options.allowUncaught = true;
|
|
529
528
|
return this;
|
|
530
529
|
};
|
|
@@ -533,7 +532,7 @@ Mocha.prototype.allowUncaught = function () {
|
|
|
533
532
|
* Delay root suite execution.
|
|
534
533
|
* @returns {Mocha}
|
|
535
534
|
*/
|
|
536
|
-
Mocha.prototype.delay = function delay
|
|
535
|
+
Mocha.prototype.delay = function delay() {
|
|
537
536
|
this.options.delay = true;
|
|
538
537
|
return this;
|
|
539
538
|
};
|
|
@@ -542,7 +541,7 @@ Mocha.prototype.delay = function delay () {
|
|
|
542
541
|
* Tests marked only fail the suite
|
|
543
542
|
* @returns {Mocha}
|
|
544
543
|
*/
|
|
545
|
-
Mocha.prototype.forbidOnly = function
|
|
544
|
+
Mocha.prototype.forbidOnly = function() {
|
|
546
545
|
this.options.forbidOnly = true;
|
|
547
546
|
return this;
|
|
548
547
|
};
|
|
@@ -551,7 +550,7 @@ Mocha.prototype.forbidOnly = function () {
|
|
|
551
550
|
* Pending tests and tests marked skip fail the suite
|
|
552
551
|
* @returns {Mocha}
|
|
553
552
|
*/
|
|
554
|
-
Mocha.prototype.forbidPending = function
|
|
553
|
+
Mocha.prototype.forbidPending = function() {
|
|
555
554
|
this.options.forbidPending = true;
|
|
556
555
|
return this;
|
|
557
556
|
};
|
|
@@ -572,7 +571,7 @@ Mocha.prototype.forbidPending = function () {
|
|
|
572
571
|
* @param {Function} fn
|
|
573
572
|
* @return {Runner}
|
|
574
573
|
*/
|
|
575
|
-
Mocha.prototype.run = function
|
|
574
|
+
Mocha.prototype.run = function(fn) {
|
|
576
575
|
if (this.files.length) {
|
|
577
576
|
this.loadFiles();
|
|
578
577
|
}
|
|
@@ -602,7 +601,7 @@ Mocha.prototype.run = function (fn) {
|
|
|
602
601
|
exports.reporters.Base.inlineDiffs = options.useInlineDiffs;
|
|
603
602
|
exports.reporters.Base.hideDiff = options.hideDiff;
|
|
604
603
|
|
|
605
|
-
function done
|
|
604
|
+
function done(failures) {
|
|
606
605
|
if (reporter.done) {
|
|
607
606
|
reporter.done(failures, fn);
|
|
608
607
|
} else {
|
package/lib/ms.js
CHANGED
|
@@ -21,7 +21,7 @@ var y = d * 365.25;
|
|
|
21
21
|
* @param {string|number} val
|
|
22
22
|
* @return {string|number}
|
|
23
23
|
*/
|
|
24
|
-
module.exports = function
|
|
24
|
+
module.exports = function(val) {
|
|
25
25
|
if (typeof val === 'string') {
|
|
26
26
|
return parse(val);
|
|
27
27
|
}
|
|
@@ -35,8 +35,10 @@ module.exports = function (val) {
|
|
|
35
35
|
* @param {string} str
|
|
36
36
|
* @return {number}
|
|
37
37
|
*/
|
|
38
|
-
function parse
|
|
39
|
-
var match =
|
|
38
|
+
function parse(str) {
|
|
39
|
+
var match = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(
|
|
40
|
+
str
|
|
41
|
+
);
|
|
40
42
|
if (!match) {
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
@@ -66,7 +68,7 @@ function parse (str) {
|
|
|
66
68
|
case 'ms':
|
|
67
69
|
return n;
|
|
68
70
|
default:
|
|
69
|
-
|
|
71
|
+
// No default case
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -77,7 +79,7 @@ function parse (str) {
|
|
|
77
79
|
* @param {number} ms
|
|
78
80
|
* @return {string}
|
|
79
81
|
*/
|
|
80
|
-
function format
|
|
82
|
+
function format(ms) {
|
|
81
83
|
if (ms >= d) {
|
|
82
84
|
return Math.round(ms / d) + 'd';
|
|
83
85
|
}
|
package/lib/pending.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Expose `Pending`.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
3
|
module.exports = Pending;
|
|
8
4
|
|
|
9
5
|
/**
|
|
@@ -11,6 +7,6 @@ module.exports = Pending;
|
|
|
11
7
|
*
|
|
12
8
|
* @param {string} message
|
|
13
9
|
*/
|
|
14
|
-
function Pending
|
|
10
|
+
function Pending(message) {
|
|
15
11
|
this.message = message;
|
|
16
12
|
}
|