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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
# 5.2.0 / 2018-05-18
|
|
2
|
+
|
|
3
|
+
## :tada: Enhancements
|
|
4
|
+
|
|
5
|
+
- [#3375]: Add support for comments in `mocha.opts` ([@plroebuck])
|
|
6
|
+
|
|
7
|
+
## :bug: Fixes
|
|
8
|
+
|
|
9
|
+
- [#3346]: Exit correctly from `before` hooks when using `--bail` ([@outsideris])
|
|
10
|
+
|
|
11
|
+
## :book: Documentation
|
|
12
|
+
|
|
13
|
+
- [#3328]: Mocha-flavored [API docs](https://mochajs.org/api/)! ([@Munter])
|
|
14
|
+
|
|
15
|
+
## :nut_and_bolt: Other
|
|
16
|
+
|
|
17
|
+
- [#3330]: Use `Buffer.from()` ([@harrysarson])
|
|
18
|
+
- [#3295]: Remove redundant folder ([@DavNej])
|
|
19
|
+
- [#3356]: Refactoring ([@plroebuck])
|
|
20
|
+
|
|
21
|
+
[#3375]: https://github.com/mochajs/mocha/pull/3375
|
|
22
|
+
[#3346]: https://github.com/mochajs/mocha/pull/3346
|
|
23
|
+
[#3328]: https://github.com/mochajs/mocha/pull/3328
|
|
24
|
+
[#3330]: https://github.com/mochajs/mocha/pull/3330
|
|
25
|
+
[#3295]: https://github.com/mochajs/mocha/pull/3295
|
|
26
|
+
[#3356]: https://github.com/mochajs/mocha/pull/3356
|
|
27
|
+
|
|
28
|
+
[@plroebuck]: https://github.com/plroebuck
|
|
29
|
+
[@harrysarson]: https://github.com/harrysarson
|
|
30
|
+
[@outsideris]: https://github.com/outsideris
|
|
31
|
+
[@Munter]: https://github.com/Munter
|
|
32
|
+
|
|
1
33
|
# 5.1.1 / 2018-04-18
|
|
2
34
|
|
|
3
35
|
## :bug: Fixes
|
package/bin/_mocha
CHANGED
|
@@ -58,7 +58,7 @@ const exit = code => {
|
|
|
58
58
|
// https://github.com/joyent/node/issues/6247 is just one bug example
|
|
59
59
|
// https://github.com/visionmedia/mocha/issues/333 has a good discussion
|
|
60
60
|
const done = () => {
|
|
61
|
-
if (!
|
|
61
|
+
if (!draining--) {
|
|
62
62
|
process.exit(clampedCode);
|
|
63
63
|
}
|
|
64
64
|
};
|
|
@@ -143,16 +143,23 @@ const requires = [];
|
|
|
143
143
|
*/
|
|
144
144
|
|
|
145
145
|
const images = {
|
|
146
|
-
fail: path.join(__dirname, '..', '
|
|
147
|
-
pass: path.join(__dirname, '..', '
|
|
146
|
+
fail: path.join(__dirname, '..', 'assets', 'growl', 'error.png'),
|
|
147
|
+
pass: path.join(__dirname, '..', 'assets', 'growl', 'ok.png')
|
|
148
148
|
};
|
|
149
149
|
|
|
150
150
|
// options
|
|
151
151
|
|
|
152
152
|
program
|
|
153
|
-
.version(
|
|
153
|
+
.version(
|
|
154
|
+
JSON.parse(
|
|
155
|
+
fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')
|
|
156
|
+
).version
|
|
157
|
+
)
|
|
154
158
|
.usage('[debug] [options] [files]')
|
|
155
|
-
.option(
|
|
159
|
+
.option(
|
|
160
|
+
'-A, --async-only',
|
|
161
|
+
'force all tests to take a callback (async) or return a promise'
|
|
162
|
+
)
|
|
156
163
|
.option('-c, --colors', 'force enabling of colors')
|
|
157
164
|
.option('-C, --no-colors', 'force disabling of colors')
|
|
158
165
|
.option('-G, --growl', 'enable growl notification support')
|
|
@@ -168,24 +175,53 @@ program
|
|
|
168
175
|
.option('-r, --require <name>', 'require the given module')
|
|
169
176
|
.option('-s, --slow <ms>', '"slow" test threshold in milliseconds [75]')
|
|
170
177
|
.option('-t, --timeout <ms>', 'set test-case timeout in milliseconds [2000]')
|
|
171
|
-
.option(
|
|
178
|
+
.option(
|
|
179
|
+
'-u, --ui <name>',
|
|
180
|
+
`specify user-interface (${interfaceNames.join('|')})`,
|
|
181
|
+
'bdd'
|
|
182
|
+
)
|
|
172
183
|
.option('-w, --watch', 'watch files for changes')
|
|
173
184
|
.option('--check-leaks', 'check for global variable leaks')
|
|
174
185
|
.option('--full-trace', 'display the full stack trace')
|
|
175
|
-
.option(
|
|
186
|
+
.option(
|
|
187
|
+
'--compilers <ext>:<module>,...',
|
|
188
|
+
'use the given module(s) to compile files',
|
|
189
|
+
list,
|
|
190
|
+
[]
|
|
191
|
+
)
|
|
176
192
|
.option('--debug-brk', "enable node's debugger breaking on the first line")
|
|
177
|
-
.option(
|
|
193
|
+
.option(
|
|
194
|
+
'--globals <names>',
|
|
195
|
+
'allow the given comma-delimited global [names]',
|
|
196
|
+
list,
|
|
197
|
+
[]
|
|
198
|
+
)
|
|
178
199
|
.option('--es_staging', 'enable all staged features')
|
|
179
|
-
.option(
|
|
180
|
-
|
|
200
|
+
.option(
|
|
201
|
+
'--harmony<_classes,_generators,...>',
|
|
202
|
+
'all node --harmony* flags are available'
|
|
203
|
+
)
|
|
204
|
+
.option(
|
|
205
|
+
'--preserve-symlinks',
|
|
206
|
+
'Instructs the module loader to preserve symbolic links when resolving and caching modules'
|
|
207
|
+
)
|
|
181
208
|
.option('--icu-data-dir', 'include ICU data')
|
|
182
|
-
.option(
|
|
209
|
+
.option(
|
|
210
|
+
'--inline-diffs',
|
|
211
|
+
'display actual/expected differences inline within each string'
|
|
212
|
+
)
|
|
183
213
|
.option('--no-diff', 'do not show a diff on failure')
|
|
184
214
|
.option('--inspect', 'activate devtools in chrome')
|
|
185
|
-
.option(
|
|
215
|
+
.option(
|
|
216
|
+
'--inspect-brk',
|
|
217
|
+
'activate devtools in chrome and break on the first line'
|
|
218
|
+
)
|
|
186
219
|
.option('--interfaces', 'display available interfaces')
|
|
187
220
|
.option('--no-deprecation', 'silence deprecation warnings')
|
|
188
|
-
.option(
|
|
221
|
+
.option(
|
|
222
|
+
'--exit',
|
|
223
|
+
'force shutdown of the event loop after test run: mocha will call process.exit'
|
|
224
|
+
)
|
|
189
225
|
.option('--no-timeouts', 'disables timeouts, given implicitly with --debug')
|
|
190
226
|
.option('--no-warnings', 'silence all node process warnings')
|
|
191
227
|
.option('--opts <path>', 'specify opts path', 'test/mocha.opts')
|
|
@@ -195,18 +231,37 @@ program
|
|
|
195
231
|
.option('--log-timer-events', 'Time events including external callbacks')
|
|
196
232
|
.option('--recursive', 'include sub directories')
|
|
197
233
|
.option('--reporters', 'display available reporters')
|
|
198
|
-
.option(
|
|
199
|
-
|
|
234
|
+
.option(
|
|
235
|
+
'--retries <times>',
|
|
236
|
+
'set numbers of time to retry a failed test case'
|
|
237
|
+
)
|
|
238
|
+
.option(
|
|
239
|
+
'--throw-deprecation',
|
|
240
|
+
'throw an exception anytime a deprecated function is used'
|
|
241
|
+
)
|
|
200
242
|
.option('--trace', 'trace function calls')
|
|
201
243
|
.option('--trace-deprecation', 'show stack traces on deprecations')
|
|
202
244
|
.option('--trace-warnings', 'show stack traces on node process warnings')
|
|
203
245
|
.option('--use_strict', 'enforce strict mode')
|
|
204
|
-
.option(
|
|
246
|
+
.option(
|
|
247
|
+
'--watch-extensions <ext>,...',
|
|
248
|
+
'additional extensions to monitor with --watch',
|
|
249
|
+
list,
|
|
250
|
+
['js']
|
|
251
|
+
)
|
|
205
252
|
.option('--delay', 'wait for async suite definition')
|
|
206
253
|
.option('--allow-uncaught', 'enable uncaught errors to propagate')
|
|
207
254
|
.option('--forbid-only', 'causes test marked with only to fail the suite')
|
|
208
|
-
.option(
|
|
209
|
-
|
|
255
|
+
.option(
|
|
256
|
+
'--forbid-pending',
|
|
257
|
+
'causes pending tests and test marked with skip to fail the suite'
|
|
258
|
+
)
|
|
259
|
+
.option(
|
|
260
|
+
'--file <file>',
|
|
261
|
+
'include a file to be ran during the suite',
|
|
262
|
+
collect,
|
|
263
|
+
[]
|
|
264
|
+
)
|
|
210
265
|
.option('--exclude <file>', 'a file or glob pattern to ignore', collect, []);
|
|
211
266
|
|
|
212
267
|
program._name = 'mocha';
|
|
@@ -312,19 +367,6 @@ if (program.reporterOptions !== undefined) {
|
|
|
312
367
|
|
|
313
368
|
mocha.reporter(program.reporter, reporterOptions);
|
|
314
369
|
|
|
315
|
-
// load reporter
|
|
316
|
-
|
|
317
|
-
let Reporter = null;
|
|
318
|
-
try {
|
|
319
|
-
Reporter = require(`../lib/reporters/${program.reporter}`);
|
|
320
|
-
} catch (err) {
|
|
321
|
-
try {
|
|
322
|
-
Reporter = require(program.reporter);
|
|
323
|
-
} catch (err2) {
|
|
324
|
-
throw new Error(`reporter "${program.reporter}" does not exist`);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
370
|
// --no-colors
|
|
329
371
|
|
|
330
372
|
if (!program.colors) {
|
|
@@ -447,7 +489,7 @@ if (program.forbidPending) mocha.forbidPending();
|
|
|
447
489
|
|
|
448
490
|
if (program.compilers.length > 0) {
|
|
449
491
|
require('util').deprecate(() => {},
|
|
450
|
-
|
|
492
|
+
'"--compilers" will be removed in a future version of Mocha; see https://git.io/vdcSr for more info')();
|
|
451
493
|
}
|
|
452
494
|
const extensions = ['js'];
|
|
453
495
|
program.compilers.forEach(c => {
|
|
@@ -489,7 +531,9 @@ args.forEach(arg => {
|
|
|
489
531
|
newFiles = utils.lookupFiles(arg, extensions, program.recursive);
|
|
490
532
|
} catch (err) {
|
|
491
533
|
if (err.message.indexOf('cannot resolve path') === 0) {
|
|
492
|
-
console.error(
|
|
534
|
+
console.error(
|
|
535
|
+
`Warning: Could not find any test files matching pattern: ${arg}`
|
|
536
|
+
);
|
|
493
537
|
return;
|
|
494
538
|
}
|
|
495
539
|
|
|
@@ -500,7 +544,9 @@ args.forEach(arg => {
|
|
|
500
544
|
if (typeof newFiles === 'string') {
|
|
501
545
|
newFiles = [newFiles];
|
|
502
546
|
}
|
|
503
|
-
newFiles = newFiles.filter(fileName =>
|
|
547
|
+
newFiles = newFiles.filter(fileName =>
|
|
548
|
+
program.exclude.every(pattern => !minimatch(fileName, pattern))
|
|
549
|
+
);
|
|
504
550
|
}
|
|
505
551
|
|
|
506
552
|
files = files.concat(newFiles);
|
|
@@ -538,7 +584,7 @@ if (program.watch) {
|
|
|
538
584
|
process.exit(130);
|
|
539
585
|
});
|
|
540
586
|
|
|
541
|
-
const watchFiles = utils.files(cwd, [
|
|
587
|
+
const watchFiles = utils.files(cwd, ['js'].concat(program.watchExtensions));
|
|
542
588
|
let runAgain = false;
|
|
543
589
|
|
|
544
590
|
loadAndRun = () => {
|
|
@@ -585,7 +631,7 @@ if (program.watch) {
|
|
|
585
631
|
}
|
|
586
632
|
});
|
|
587
633
|
} else {
|
|
588
|
-
// load
|
|
634
|
+
// load
|
|
589
635
|
|
|
590
636
|
mocha.files = files;
|
|
591
637
|
runner = mocha.run(program.exit ? exit : exitLater);
|
package/bin/options.js
CHANGED
|
@@ -16,17 +16,23 @@ module.exports = getOptions;
|
|
|
16
16
|
* Get options.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
function getOptions
|
|
20
|
-
if (
|
|
19
|
+
function getOptions() {
|
|
20
|
+
if (
|
|
21
|
+
process.argv.length === 3 &&
|
|
22
|
+
(process.argv[2] === '-h' || process.argv[2] === '--help')
|
|
23
|
+
) {
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
const optsPath =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const optsPath =
|
|
28
|
+
process.argv.indexOf('--opts') === -1
|
|
29
|
+
? 'test/mocha.opts'
|
|
30
|
+
: process.argv[process.argv.indexOf('--opts') + 1];
|
|
27
31
|
|
|
28
32
|
try {
|
|
29
|
-
const opts = fs
|
|
33
|
+
const opts = fs
|
|
34
|
+
.readFileSync(optsPath, 'utf8')
|
|
35
|
+
.replace(/^#.*$/gm, '')
|
|
30
36
|
.replace(/\\\s/g, '%20')
|
|
31
37
|
.split(/\s/)
|
|
32
38
|
.filter(Boolean)
|
|
@@ -35,8 +41,8 @@ function getOptions () {
|
|
|
35
41
|
process.argv = process.argv
|
|
36
42
|
.slice(0, 2)
|
|
37
43
|
.concat(opts.concat(process.argv.slice(2)));
|
|
38
|
-
} catch (
|
|
39
|
-
//
|
|
44
|
+
} catch (ignore) {
|
|
45
|
+
// NOTE: should console.error() and throw the error
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
process.env.LOADED_MOCHA_OPTS = true;
|
package/browser-entry.js
CHANGED
|
@@ -17,7 +17,7 @@ var Mocha = require('./lib/mocha');
|
|
|
17
17
|
* @return {undefined}
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
var mocha = new Mocha({
|
|
20
|
+
var mocha = new Mocha({reporter: 'html'});
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Save timer references to avoid Sinon interfering (see GH-237).
|
|
@@ -38,12 +38,12 @@ var originalOnerrorHandler = global.onerror;
|
|
|
38
38
|
* Revert to original onerror handler if previously defined.
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
|
-
process.removeListener = function
|
|
41
|
+
process.removeListener = function(e, fn) {
|
|
42
42
|
if (e === 'uncaughtException') {
|
|
43
43
|
if (originalOnerrorHandler) {
|
|
44
44
|
global.onerror = originalOnerrorHandler;
|
|
45
45
|
} else {
|
|
46
|
-
global.onerror = function
|
|
46
|
+
global.onerror = function() {};
|
|
47
47
|
}
|
|
48
48
|
var i = uncaughtExceptionHandlers.indexOf(fn);
|
|
49
49
|
if (i !== -1) {
|
|
@@ -56,9 +56,9 @@ process.removeListener = function (e, fn) {
|
|
|
56
56
|
* Implements uncaughtException listener.
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
|
-
process.on = function
|
|
59
|
+
process.on = function(e, fn) {
|
|
60
60
|
if (e === 'uncaughtException') {
|
|
61
|
-
global.onerror = function
|
|
61
|
+
global.onerror = function(err, url, line) {
|
|
62
62
|
fn(new Error(err + ' (' + url + ':' + line + ')'));
|
|
63
63
|
return !mocha.allowUncaught;
|
|
64
64
|
};
|
|
@@ -74,9 +74,9 @@ mocha.suite.removeAllListeners('pre-require');
|
|
|
74
74
|
var immediateQueue = [];
|
|
75
75
|
var immediateTimeout;
|
|
76
76
|
|
|
77
|
-
function timeslice
|
|
77
|
+
function timeslice() {
|
|
78
78
|
var immediateStart = new Date().getTime();
|
|
79
|
-
while (immediateQueue.length &&
|
|
79
|
+
while (immediateQueue.length && new Date().getTime() - immediateStart < 100) {
|
|
80
80
|
immediateQueue.shift()();
|
|
81
81
|
}
|
|
82
82
|
if (immediateQueue.length) {
|
|
@@ -90,7 +90,7 @@ function timeslice () {
|
|
|
90
90
|
* High-performance override of Runner.immediately.
|
|
91
91
|
*/
|
|
92
92
|
|
|
93
|
-
Mocha.Runner.immediately = function
|
|
93
|
+
Mocha.Runner.immediately = function(callback) {
|
|
94
94
|
immediateQueue.push(callback);
|
|
95
95
|
if (!immediateTimeout) {
|
|
96
96
|
immediateTimeout = setTimeout(timeslice, 0);
|
|
@@ -102,8 +102,8 @@ Mocha.Runner.immediately = function (callback) {
|
|
|
102
102
|
* This is useful when running tests in a browser because window.onerror will
|
|
103
103
|
* only receive the 'message' attribute of the Error.
|
|
104
104
|
*/
|
|
105
|
-
mocha.throwError = function
|
|
106
|
-
uncaughtExceptionHandlers.forEach(function
|
|
105
|
+
mocha.throwError = function(err) {
|
|
106
|
+
uncaughtExceptionHandlers.forEach(function(fn) {
|
|
107
107
|
fn(err);
|
|
108
108
|
});
|
|
109
109
|
throw err;
|
|
@@ -114,7 +114,7 @@ mocha.throwError = function (err) {
|
|
|
114
114
|
* Normally this would happen in Mocha.prototype.loadFiles.
|
|
115
115
|
*/
|
|
116
116
|
|
|
117
|
-
mocha.ui = function
|
|
117
|
+
mocha.ui = function(ui) {
|
|
118
118
|
Mocha.prototype.ui.call(this, ui);
|
|
119
119
|
this.suite.emit('pre-require', global, null, this);
|
|
120
120
|
return this;
|
|
@@ -124,9 +124,9 @@ mocha.ui = function (ui) {
|
|
|
124
124
|
* Setup mocha with the given setting options.
|
|
125
125
|
*/
|
|
126
126
|
|
|
127
|
-
mocha.setup = function
|
|
127
|
+
mocha.setup = function(opts) {
|
|
128
128
|
if (typeof opts === 'string') {
|
|
129
|
-
opts = {
|
|
129
|
+
opts = {ui: opts};
|
|
130
130
|
}
|
|
131
131
|
for (var opt in opts) {
|
|
132
132
|
if (opts.hasOwnProperty(opt)) {
|
|
@@ -140,7 +140,7 @@ mocha.setup = function (opts) {
|
|
|
140
140
|
* Run mocha, returning the Runner.
|
|
141
141
|
*/
|
|
142
142
|
|
|
143
|
-
mocha.run = function
|
|
143
|
+
mocha.run = function(fn) {
|
|
144
144
|
var options = mocha.options;
|
|
145
145
|
mocha.globals('location');
|
|
146
146
|
|
|
@@ -155,10 +155,14 @@ mocha.run = function (fn) {
|
|
|
155
155
|
mocha.invert();
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
return Mocha.prototype.run.call(mocha, function
|
|
158
|
+
return Mocha.prototype.run.call(mocha, function(err) {
|
|
159
159
|
// The DOM Document is not available in Web Workers.
|
|
160
160
|
var document = global.document;
|
|
161
|
-
if (
|
|
161
|
+
if (
|
|
162
|
+
document &&
|
|
163
|
+
document.getElementById('mocha') &&
|
|
164
|
+
options.noHighlighting !== true
|
|
165
|
+
) {
|
|
162
166
|
Mocha.utils.highlightTags('code');
|
|
163
167
|
}
|
|
164
168
|
if (fn) {
|
package/lib/browser/progress.js
CHANGED
|
@@ -9,7 +9,7 @@ module.exports = Progress;
|
|
|
9
9
|
/**
|
|
10
10
|
* Initialize a new `Progress` indicator.
|
|
11
11
|
*/
|
|
12
|
-
function Progress
|
|
12
|
+
function Progress() {
|
|
13
13
|
this.percent = 0;
|
|
14
14
|
this.size(0);
|
|
15
15
|
this.fontSize(11);
|
|
@@ -23,7 +23,7 @@ function Progress () {
|
|
|
23
23
|
* @param {number} size
|
|
24
24
|
* @return {Progress} Progress instance.
|
|
25
25
|
*/
|
|
26
|
-
Progress.prototype.size = function
|
|
26
|
+
Progress.prototype.size = function(size) {
|
|
27
27
|
this._size = size;
|
|
28
28
|
return this;
|
|
29
29
|
};
|
|
@@ -35,7 +35,7 @@ Progress.prototype.size = function (size) {
|
|
|
35
35
|
* @param {string} text
|
|
36
36
|
* @return {Progress} Progress instance.
|
|
37
37
|
*/
|
|
38
|
-
Progress.prototype.text = function
|
|
38
|
+
Progress.prototype.text = function(text) {
|
|
39
39
|
this._text = text;
|
|
40
40
|
return this;
|
|
41
41
|
};
|
|
@@ -47,7 +47,7 @@ Progress.prototype.text = function (text) {
|
|
|
47
47
|
* @param {number} size
|
|
48
48
|
* @return {Progress} Progress instance.
|
|
49
49
|
*/
|
|
50
|
-
Progress.prototype.fontSize = function
|
|
50
|
+
Progress.prototype.fontSize = function(size) {
|
|
51
51
|
this._fontSize = size;
|
|
52
52
|
return this;
|
|
53
53
|
};
|
|
@@ -58,7 +58,7 @@ Progress.prototype.fontSize = function (size) {
|
|
|
58
58
|
* @param {string} family
|
|
59
59
|
* @return {Progress} Progress instance.
|
|
60
60
|
*/
|
|
61
|
-
Progress.prototype.font = function
|
|
61
|
+
Progress.prototype.font = function(family) {
|
|
62
62
|
this._font = family;
|
|
63
63
|
return this;
|
|
64
64
|
};
|
|
@@ -69,7 +69,7 @@ Progress.prototype.font = function (family) {
|
|
|
69
69
|
* @param {number} n
|
|
70
70
|
* @return {Progress} Progress instance.
|
|
71
71
|
*/
|
|
72
|
-
Progress.prototype.update = function
|
|
72
|
+
Progress.prototype.update = function(n) {
|
|
73
73
|
this.percent = n;
|
|
74
74
|
return this;
|
|
75
75
|
};
|
|
@@ -80,7 +80,7 @@ Progress.prototype.update = function (n) {
|
|
|
80
80
|
* @param {CanvasRenderingContext2d} ctx
|
|
81
81
|
* @return {Progress} Progress instance.
|
|
82
82
|
*/
|
|
83
|
-
Progress.prototype.draw = function
|
|
83
|
+
Progress.prototype.draw = function(ctx) {
|
|
84
84
|
try {
|
|
85
85
|
var percent = Math.min(this.percent, 100);
|
|
86
86
|
var size = this._size;
|
|
@@ -112,7 +112,7 @@ Progress.prototype.draw = function (ctx) {
|
|
|
112
112
|
var w = ctx.measureText(text).width;
|
|
113
113
|
|
|
114
114
|
ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
|
|
115
|
-
} catch (
|
|
115
|
+
} catch (ignore) {
|
|
116
116
|
// don't fail if we can't render progress
|
|
117
117
|
}
|
|
118
118
|
return this;
|
package/lib/browser/tty.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
exports.isatty = function isatty
|
|
3
|
+
exports.isatty = function isatty() {
|
|
4
4
|
return true;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
exports.getWindowSize = function getWindowSize
|
|
7
|
+
exports.getWindowSize = function getWindowSize() {
|
|
8
8
|
if ('innerHeight' in global) {
|
|
9
9
|
return [global.innerHeight, global.innerWidth];
|
|
10
10
|
}
|
package/lib/context.js
CHANGED
|
@@ -13,7 +13,7 @@ module.exports = Context;
|
|
|
13
13
|
*
|
|
14
14
|
* @api private
|
|
15
15
|
*/
|
|
16
|
-
function Context
|
|
16
|
+
function Context() {}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Set or get the context `Runnable` to `runnable`.
|
|
@@ -22,7 +22,7 @@ function Context () {}
|
|
|
22
22
|
* @param {Runnable} runnable
|
|
23
23
|
* @return {Context} context
|
|
24
24
|
*/
|
|
25
|
-
Context.prototype.runnable = function
|
|
25
|
+
Context.prototype.runnable = function(runnable) {
|
|
26
26
|
if (!arguments.length) {
|
|
27
27
|
return this._runnable;
|
|
28
28
|
}
|
|
@@ -37,7 +37,7 @@ Context.prototype.runnable = function (runnable) {
|
|
|
37
37
|
* @param {number} ms
|
|
38
38
|
* @return {Context} self
|
|
39
39
|
*/
|
|
40
|
-
Context.prototype.timeout = function
|
|
40
|
+
Context.prototype.timeout = function(ms) {
|
|
41
41
|
if (!arguments.length) {
|
|
42
42
|
return this.runnable().timeout();
|
|
43
43
|
}
|
|
@@ -52,7 +52,7 @@ Context.prototype.timeout = function (ms) {
|
|
|
52
52
|
* @param {boolean} enabled
|
|
53
53
|
* @return {Context} self
|
|
54
54
|
*/
|
|
55
|
-
Context.prototype.enableTimeouts = function
|
|
55
|
+
Context.prototype.enableTimeouts = function(enabled) {
|
|
56
56
|
if (!arguments.length) {
|
|
57
57
|
return this.runnable().enableTimeouts();
|
|
58
58
|
}
|
|
@@ -67,7 +67,7 @@ Context.prototype.enableTimeouts = function (enabled) {
|
|
|
67
67
|
* @param {number} ms
|
|
68
68
|
* @return {Context} self
|
|
69
69
|
*/
|
|
70
|
-
Context.prototype.slow = function
|
|
70
|
+
Context.prototype.slow = function(ms) {
|
|
71
71
|
if (!arguments.length) {
|
|
72
72
|
return this.runnable().slow();
|
|
73
73
|
}
|
|
@@ -81,7 +81,7 @@ Context.prototype.slow = function (ms) {
|
|
|
81
81
|
* @api private
|
|
82
82
|
* @throws Pending
|
|
83
83
|
*/
|
|
84
|
-
Context.prototype.skip = function
|
|
84
|
+
Context.prototype.skip = function() {
|
|
85
85
|
this.runnable().skip();
|
|
86
86
|
};
|
|
87
87
|
|
|
@@ -92,7 +92,7 @@ Context.prototype.skip = function () {
|
|
|
92
92
|
* @param {number} n
|
|
93
93
|
* @return {Context} self
|
|
94
94
|
*/
|
|
95
|
-
Context.prototype.retries = function
|
|
95
|
+
Context.prototype.retries = function(n) {
|
|
96
96
|
if (!arguments.length) {
|
|
97
97
|
return this.runnable().retries();
|
|
98
98
|
}
|
package/lib/hook.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* @module Hook
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Module dependencies.
|
|
8
|
-
*/
|
|
9
2
|
|
|
10
3
|
var Runnable = require('./runnable');
|
|
11
4
|
var inherits = require('./utils').inherits;
|
|
@@ -17,17 +10,14 @@ var inherits = require('./utils').inherits;
|
|
|
17
10
|
module.exports = Hook;
|
|
18
11
|
|
|
19
12
|
/**
|
|
20
|
-
* Initialize a new `Hook` with the given `title` and callback `fn
|
|
21
|
-
* `Runnable`.
|
|
13
|
+
* Initialize a new `Hook` with the given `title` and callback `fn`
|
|
22
14
|
*
|
|
23
|
-
* @memberof Mocha
|
|
24
|
-
* @public
|
|
25
15
|
* @class
|
|
16
|
+
* @extends Runnable
|
|
26
17
|
* @param {String} title
|
|
27
18
|
* @param {Function} fn
|
|
28
|
-
* @api private
|
|
29
19
|
*/
|
|
30
|
-
function Hook
|
|
20
|
+
function Hook(title, fn) {
|
|
31
21
|
Runnable.call(this, title, fn);
|
|
32
22
|
this.type = 'hook';
|
|
33
23
|
}
|
|
@@ -40,13 +30,12 @@ inherits(Hook, Runnable);
|
|
|
40
30
|
/**
|
|
41
31
|
* Get or set the test `err`.
|
|
42
32
|
*
|
|
43
|
-
* @memberof
|
|
33
|
+
* @memberof Hook
|
|
44
34
|
* @public
|
|
45
35
|
* @param {Error} err
|
|
46
36
|
* @return {Error}
|
|
47
|
-
* @api public
|
|
48
37
|
*/
|
|
49
|
-
Hook.prototype.error = function
|
|
38
|
+
Hook.prototype.error = function(err) {
|
|
50
39
|
if (!arguments.length) {
|
|
51
40
|
err = this._error;
|
|
52
41
|
this._error = null;
|
package/lib/interfaces/bdd.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
|
/**
|
|
@@ -23,10 +19,10 @@ var Test = require('../test');
|
|
|
23
19
|
*
|
|
24
20
|
* @param {Suite} suite Root suite.
|
|
25
21
|
*/
|
|
26
|
-
module.exports = function (suite) {
|
|
22
|
+
module.exports = function bddInterface(suite) {
|
|
27
23
|
var suites = [suite];
|
|
28
24
|
|
|
29
|
-
suite.on('pre-require', function
|
|
25
|
+
suite.on('pre-require', function(context, file, mocha) {
|
|
30
26
|
var common = require('./common')(suites, context, mocha);
|
|
31
27
|
|
|
32
28
|
context.before = common.before;
|
|
@@ -40,7 +36,7 @@ module.exports = function (suite) {
|
|
|
40
36
|
* and/or tests.
|
|
41
37
|
*/
|
|
42
38
|
|
|
43
|
-
context.describe = context.context = function
|
|
39
|
+
context.describe = context.context = function(title, fn) {
|
|
44
40
|
return common.suite.create({
|
|
45
41
|
title: title,
|
|
46
42
|
file: file,
|
|
@@ -52,7 +48,10 @@ module.exports = function (suite) {
|
|
|
52
48
|
* Pending describe.
|
|
53
49
|
*/
|
|
54
50
|
|
|
55
|
-
context.xdescribe = context.xcontext = context.describe.skip = function
|
|
51
|
+
context.xdescribe = context.xcontext = context.describe.skip = function(
|
|
52
|
+
title,
|
|
53
|
+
fn
|
|
54
|
+
) {
|
|
56
55
|
return common.suite.skip({
|
|
57
56
|
title: title,
|
|
58
57
|
file: file,
|
|
@@ -64,7 +63,7 @@ module.exports = function (suite) {
|
|
|
64
63
|
* Exclusive suite.
|
|
65
64
|
*/
|
|
66
65
|
|
|
67
|
-
context.describe.only = function
|
|
66
|
+
context.describe.only = function(title, fn) {
|
|
68
67
|
return common.suite.only({
|
|
69
68
|
title: title,
|
|
70
69
|
file: file,
|
|
@@ -78,7 +77,7 @@ module.exports = function (suite) {
|
|
|
78
77
|
* acting as a thunk.
|
|
79
78
|
*/
|
|
80
79
|
|
|
81
|
-
context.it = context.specify = function
|
|
80
|
+
context.it = context.specify = function(title, fn) {
|
|
82
81
|
var suite = suites[0];
|
|
83
82
|
if (suite.isPending()) {
|
|
84
83
|
fn = null;
|
|
@@ -93,7 +92,7 @@ module.exports = function (suite) {
|
|
|
93
92
|
* Exclusive test-case.
|
|
94
93
|
*/
|
|
95
94
|
|
|
96
|
-
context.it.only = function
|
|
95
|
+
context.it.only = function(title, fn) {
|
|
97
96
|
return common.test.only(mocha, context.it(title, fn));
|
|
98
97
|
};
|
|
99
98
|
|
|
@@ -101,14 +100,14 @@ module.exports = function (suite) {
|
|
|
101
100
|
* Pending test case.
|
|
102
101
|
*/
|
|
103
102
|
|
|
104
|
-
context.xit = context.xspecify = context.it.skip = function
|
|
103
|
+
context.xit = context.xspecify = context.it.skip = function(title) {
|
|
105
104
|
return context.it(title);
|
|
106
105
|
};
|
|
107
106
|
|
|
108
107
|
/**
|
|
109
108
|
* Number of attempts to retry.
|
|
110
109
|
*/
|
|
111
|
-
context.it.retries = function
|
|
110
|
+
context.it.retries = function(n) {
|
|
112
111
|
context.retries(n);
|
|
113
112
|
};
|
|
114
113
|
});
|