mocha 6.1.0 → 6.1.4
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 +1776 -1751
- package/LICENSE +22 -22
- package/README.md +105 -105
- package/bin/_mocha +10 -10
- package/bin/mocha +149 -149
- package/bin/options.js +10 -10
- package/browser-entry.js +191 -191
- package/index.js +3 -3
- package/lib/browser/growl.js +168 -168
- package/lib/browser/progress.js +119 -119
- package/lib/browser/template.html +18 -18
- package/lib/browser/tty.js +13 -13
- package/lib/cli/cli.js +69 -69
- package/lib/cli/commands.js +13 -13
- package/lib/cli/config.js +101 -101
- package/lib/cli/index.js +9 -9
- package/lib/cli/init.js +37 -37
- package/lib/cli/node-flags.js +86 -86
- package/lib/cli/one-and-dones.js +70 -70
- package/lib/cli/options.js +347 -347
- package/lib/cli/run-helpers.js +337 -337
- package/lib/cli/run-option-metadata.js +76 -76
- package/lib/cli/run.js +297 -297
- package/lib/context.js +101 -101
- package/lib/errors.js +141 -141
- package/lib/growl.js +136 -136
- package/lib/hook.js +46 -46
- package/lib/interfaces/bdd.js +118 -118
- package/lib/interfaces/common.js +191 -191
- package/lib/interfaces/exports.js +60 -60
- package/lib/interfaces/index.js +6 -6
- package/lib/interfaces/qunit.js +99 -99
- package/lib/interfaces/tdd.js +107 -107
- package/lib/mocha.js +843 -843
- package/lib/mocharc.json +10 -10
- package/lib/pending.js +12 -12
- package/lib/reporters/base.js +491 -491
- package/lib/reporters/doc.js +85 -85
- package/lib/reporters/dot.js +81 -81
- package/lib/reporters/html.js +390 -390
- package/lib/reporters/index.js +19 -19
- package/lib/reporters/json-stream.js +90 -90
- package/lib/reporters/json.js +135 -135
- package/lib/reporters/landing.js +108 -108
- package/lib/reporters/list.js +78 -78
- package/lib/reporters/markdown.js +112 -112
- package/lib/reporters/min.js +52 -52
- package/lib/reporters/nyan.js +276 -276
- package/lib/reporters/progress.js +104 -104
- package/lib/reporters/spec.js +99 -99
- package/lib/reporters/tap.js +294 -294
- package/lib/reporters/xunit.js +216 -216
- package/lib/runnable.js +496 -496
- package/lib/runner.js +1049 -1049
- package/lib/stats-collector.js +83 -83
- package/lib/suite.js +642 -642
- package/lib/test.js +51 -51
- package/lib/utils.js +897 -897
- package/mocha.css +326 -326
- package/mocha.js +8170 -8476
- package/package.json +630 -628
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* @module Progress
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Module dependencies.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
var Base = require('./base');
|
|
10
|
-
var constants = require('../runner').constants;
|
|
11
|
-
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
|
12
|
-
var EVENT_TEST_END = constants.EVENT_TEST_END;
|
|
13
|
-
var EVENT_RUN_END = constants.EVENT_RUN_END;
|
|
14
|
-
var inherits = require('../utils').inherits;
|
|
15
|
-
var color = Base.color;
|
|
16
|
-
var cursor = Base.cursor;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Expose `Progress`.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
exports = module.exports = Progress;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* General progress bar color.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
Base.colors.progress = 90;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Constructs a new `Progress` reporter instance.
|
|
32
|
-
*
|
|
33
|
-
* @public
|
|
34
|
-
* @class
|
|
35
|
-
* @memberof Mocha.reporters
|
|
36
|
-
* @extends Mocha.reporters.Base
|
|
37
|
-
* @param {Runner} runner - Instance triggers reporter actions.
|
|
38
|
-
* @param {Object} [options] - runner options
|
|
39
|
-
*/
|
|
40
|
-
function Progress(runner, options) {
|
|
41
|
-
Base.call(this, runner, options);
|
|
42
|
-
|
|
43
|
-
var self = this;
|
|
44
|
-
var width = (Base.window.width * 0.5) | 0;
|
|
45
|
-
var total = runner.total;
|
|
46
|
-
var complete = 0;
|
|
47
|
-
var lastN = -1;
|
|
48
|
-
|
|
49
|
-
// default chars
|
|
50
|
-
options = options || {};
|
|
51
|
-
var reporterOptions = options.reporterOptions || {};
|
|
52
|
-
|
|
53
|
-
options.open = reporterOptions.open || '[';
|
|
54
|
-
options.complete = reporterOptions.complete || '▬';
|
|
55
|
-
options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
|
|
56
|
-
options.close = reporterOptions.close || ']';
|
|
57
|
-
options.verbose = reporterOptions.verbose || false;
|
|
58
|
-
|
|
59
|
-
// tests started
|
|
60
|
-
runner.on(EVENT_RUN_BEGIN, function() {
|
|
61
|
-
console.log();
|
|
62
|
-
cursor.hide();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// tests complete
|
|
66
|
-
runner.on(EVENT_TEST_END, function() {
|
|
67
|
-
complete++;
|
|
68
|
-
|
|
69
|
-
var percent = complete / total;
|
|
70
|
-
var n = (width * percent) | 0;
|
|
71
|
-
var i = width - n;
|
|
72
|
-
|
|
73
|
-
if (n === lastN && !options.verbose) {
|
|
74
|
-
// Don't re-render the line if it hasn't changed
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
lastN = n;
|
|
78
|
-
|
|
79
|
-
cursor.CR();
|
|
80
|
-
process.stdout.write('\u001b[J');
|
|
81
|
-
process.stdout.write(color('progress', ' ' + options.open));
|
|
82
|
-
process.stdout.write(Array(n).join(options.complete));
|
|
83
|
-
process.stdout.write(Array(i).join(options.incomplete));
|
|
84
|
-
process.stdout.write(color('progress', options.close));
|
|
85
|
-
if (options.verbose) {
|
|
86
|
-
process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
// tests are complete, output some stats
|
|
91
|
-
// and the failures if any
|
|
92
|
-
runner.once(EVENT_RUN_END, function() {
|
|
93
|
-
cursor.show();
|
|
94
|
-
console.log();
|
|
95
|
-
self.epilogue();
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Inherit from `Base.prototype`.
|
|
101
|
-
*/
|
|
102
|
-
inherits(Progress, Base);
|
|
103
|
-
|
|
104
|
-
Progress.description = 'a progress bar';
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @module Progress
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Module dependencies.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var Base = require('./base');
|
|
10
|
+
var constants = require('../runner').constants;
|
|
11
|
+
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
|
12
|
+
var EVENT_TEST_END = constants.EVENT_TEST_END;
|
|
13
|
+
var EVENT_RUN_END = constants.EVENT_RUN_END;
|
|
14
|
+
var inherits = require('../utils').inherits;
|
|
15
|
+
var color = Base.color;
|
|
16
|
+
var cursor = Base.cursor;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Expose `Progress`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
exports = module.exports = Progress;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* General progress bar color.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
Base.colors.progress = 90;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Constructs a new `Progress` reporter instance.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
* @class
|
|
35
|
+
* @memberof Mocha.reporters
|
|
36
|
+
* @extends Mocha.reporters.Base
|
|
37
|
+
* @param {Runner} runner - Instance triggers reporter actions.
|
|
38
|
+
* @param {Object} [options] - runner options
|
|
39
|
+
*/
|
|
40
|
+
function Progress(runner, options) {
|
|
41
|
+
Base.call(this, runner, options);
|
|
42
|
+
|
|
43
|
+
var self = this;
|
|
44
|
+
var width = (Base.window.width * 0.5) | 0;
|
|
45
|
+
var total = runner.total;
|
|
46
|
+
var complete = 0;
|
|
47
|
+
var lastN = -1;
|
|
48
|
+
|
|
49
|
+
// default chars
|
|
50
|
+
options = options || {};
|
|
51
|
+
var reporterOptions = options.reporterOptions || {};
|
|
52
|
+
|
|
53
|
+
options.open = reporterOptions.open || '[';
|
|
54
|
+
options.complete = reporterOptions.complete || '▬';
|
|
55
|
+
options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
|
|
56
|
+
options.close = reporterOptions.close || ']';
|
|
57
|
+
options.verbose = reporterOptions.verbose || false;
|
|
58
|
+
|
|
59
|
+
// tests started
|
|
60
|
+
runner.on(EVENT_RUN_BEGIN, function() {
|
|
61
|
+
console.log();
|
|
62
|
+
cursor.hide();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// tests complete
|
|
66
|
+
runner.on(EVENT_TEST_END, function() {
|
|
67
|
+
complete++;
|
|
68
|
+
|
|
69
|
+
var percent = complete / total;
|
|
70
|
+
var n = (width * percent) | 0;
|
|
71
|
+
var i = width - n;
|
|
72
|
+
|
|
73
|
+
if (n === lastN && !options.verbose) {
|
|
74
|
+
// Don't re-render the line if it hasn't changed
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
lastN = n;
|
|
78
|
+
|
|
79
|
+
cursor.CR();
|
|
80
|
+
process.stdout.write('\u001b[J');
|
|
81
|
+
process.stdout.write(color('progress', ' ' + options.open));
|
|
82
|
+
process.stdout.write(Array(n).join(options.complete));
|
|
83
|
+
process.stdout.write(Array(i).join(options.incomplete));
|
|
84
|
+
process.stdout.write(color('progress', options.close));
|
|
85
|
+
if (options.verbose) {
|
|
86
|
+
process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// tests are complete, output some stats
|
|
91
|
+
// and the failures if any
|
|
92
|
+
runner.once(EVENT_RUN_END, function() {
|
|
93
|
+
cursor.show();
|
|
94
|
+
console.log();
|
|
95
|
+
self.epilogue();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Inherit from `Base.prototype`.
|
|
101
|
+
*/
|
|
102
|
+
inherits(Progress, Base);
|
|
103
|
+
|
|
104
|
+
Progress.description = 'a progress bar';
|
package/lib/reporters/spec.js
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* @module Spec
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Module dependencies.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
var Base = require('./base');
|
|
10
|
-
var constants = require('../runner').constants;
|
|
11
|
-
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
|
12
|
-
var EVENT_RUN_END = constants.EVENT_RUN_END;
|
|
13
|
-
var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
|
|
14
|
-
var EVENT_SUITE_END = constants.EVENT_SUITE_END;
|
|
15
|
-
var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
|
|
16
|
-
var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
|
|
17
|
-
var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
|
|
18
|
-
var inherits = require('../utils').inherits;
|
|
19
|
-
var color = Base.color;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Expose `Spec`.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
exports = module.exports = Spec;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Constructs a new `Spec` reporter instance.
|
|
29
|
-
*
|
|
30
|
-
* @public
|
|
31
|
-
* @class
|
|
32
|
-
* @memberof Mocha.reporters
|
|
33
|
-
* @extends Mocha.reporters.Base
|
|
34
|
-
* @param {Runner} runner - Instance triggers reporter actions.
|
|
35
|
-
* @param {Object} [options] - runner options
|
|
36
|
-
*/
|
|
37
|
-
function Spec(runner, options) {
|
|
38
|
-
Base.call(this, runner, options);
|
|
39
|
-
|
|
40
|
-
var self = this;
|
|
41
|
-
var indents = 0;
|
|
42
|
-
var n = 0;
|
|
43
|
-
|
|
44
|
-
function indent() {
|
|
45
|
-
return Array(indents).join(' ');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
runner.on(EVENT_RUN_BEGIN, function() {
|
|
49
|
-
console.log();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
runner.on(EVENT_SUITE_BEGIN, function(suite) {
|
|
53
|
-
++indents;
|
|
54
|
-
console.log(color('suite', '%s%s'), indent(), suite.title);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
runner.on(EVENT_SUITE_END, function() {
|
|
58
|
-
--indents;
|
|
59
|
-
if (indents === 1) {
|
|
60
|
-
console.log();
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
runner.on(EVENT_TEST_PENDING, function(test) {
|
|
65
|
-
var fmt = indent() + color('pending', ' - %s');
|
|
66
|
-
console.log(fmt, test.title);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
runner.on(EVENT_TEST_PASS, function(test) {
|
|
70
|
-
var fmt;
|
|
71
|
-
if (test.speed === 'fast') {
|
|
72
|
-
fmt =
|
|
73
|
-
indent() +
|
|
74
|
-
color('checkmark', ' ' + Base.symbols.ok) +
|
|
75
|
-
color('pass', ' %s');
|
|
76
|
-
console.log(fmt, test.title);
|
|
77
|
-
} else {
|
|
78
|
-
fmt =
|
|
79
|
-
indent() +
|
|
80
|
-
color('checkmark', ' ' + Base.symbols.ok) +
|
|
81
|
-
color('pass', ' %s') +
|
|
82
|
-
color(test.speed, ' (%dms)');
|
|
83
|
-
console.log(fmt, test.title, test.duration);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
runner.on(EVENT_TEST_FAIL, function(test) {
|
|
88
|
-
console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
runner.once(EVENT_RUN_END, self.epilogue.bind(self));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Inherit from `Base.prototype`.
|
|
96
|
-
*/
|
|
97
|
-
inherits(Spec, Base);
|
|
98
|
-
|
|
99
|
-
Spec.description = 'hierarchical & verbose [default]';
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @module Spec
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Module dependencies.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var Base = require('./base');
|
|
10
|
+
var constants = require('../runner').constants;
|
|
11
|
+
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
|
12
|
+
var EVENT_RUN_END = constants.EVENT_RUN_END;
|
|
13
|
+
var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
|
|
14
|
+
var EVENT_SUITE_END = constants.EVENT_SUITE_END;
|
|
15
|
+
var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
|
|
16
|
+
var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
|
|
17
|
+
var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
|
|
18
|
+
var inherits = require('../utils').inherits;
|
|
19
|
+
var color = Base.color;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Expose `Spec`.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
exports = module.exports = Spec;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a new `Spec` reporter instance.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @class
|
|
32
|
+
* @memberof Mocha.reporters
|
|
33
|
+
* @extends Mocha.reporters.Base
|
|
34
|
+
* @param {Runner} runner - Instance triggers reporter actions.
|
|
35
|
+
* @param {Object} [options] - runner options
|
|
36
|
+
*/
|
|
37
|
+
function Spec(runner, options) {
|
|
38
|
+
Base.call(this, runner, options);
|
|
39
|
+
|
|
40
|
+
var self = this;
|
|
41
|
+
var indents = 0;
|
|
42
|
+
var n = 0;
|
|
43
|
+
|
|
44
|
+
function indent() {
|
|
45
|
+
return Array(indents).join(' ');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
runner.on(EVENT_RUN_BEGIN, function() {
|
|
49
|
+
console.log();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
runner.on(EVENT_SUITE_BEGIN, function(suite) {
|
|
53
|
+
++indents;
|
|
54
|
+
console.log(color('suite', '%s%s'), indent(), suite.title);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
runner.on(EVENT_SUITE_END, function() {
|
|
58
|
+
--indents;
|
|
59
|
+
if (indents === 1) {
|
|
60
|
+
console.log();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
runner.on(EVENT_TEST_PENDING, function(test) {
|
|
65
|
+
var fmt = indent() + color('pending', ' - %s');
|
|
66
|
+
console.log(fmt, test.title);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
runner.on(EVENT_TEST_PASS, function(test) {
|
|
70
|
+
var fmt;
|
|
71
|
+
if (test.speed === 'fast') {
|
|
72
|
+
fmt =
|
|
73
|
+
indent() +
|
|
74
|
+
color('checkmark', ' ' + Base.symbols.ok) +
|
|
75
|
+
color('pass', ' %s');
|
|
76
|
+
console.log(fmt, test.title);
|
|
77
|
+
} else {
|
|
78
|
+
fmt =
|
|
79
|
+
indent() +
|
|
80
|
+
color('checkmark', ' ' + Base.symbols.ok) +
|
|
81
|
+
color('pass', ' %s') +
|
|
82
|
+
color(test.speed, ' (%dms)');
|
|
83
|
+
console.log(fmt, test.title, test.duration);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
runner.on(EVENT_TEST_FAIL, function(test) {
|
|
88
|
+
console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
runner.once(EVENT_RUN_END, self.epilogue.bind(self));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Inherit from `Base.prototype`.
|
|
96
|
+
*/
|
|
97
|
+
inherits(Spec, Base);
|
|
98
|
+
|
|
99
|
+
Spec.description = 'hierarchical & verbose [default]';
|