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
package/lib/context.js
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* @module Context
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Expose `Context`.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
module.exports = Context;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Initialize a new `Context`.
|
|
13
|
-
*
|
|
14
|
-
* @private
|
|
15
|
-
*/
|
|
16
|
-
function Context() {}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Set or get the context `Runnable` to `runnable`.
|
|
20
|
-
*
|
|
21
|
-
* @private
|
|
22
|
-
* @param {Runnable} runnable
|
|
23
|
-
* @return {Context} context
|
|
24
|
-
*/
|
|
25
|
-
Context.prototype.runnable = function(runnable) {
|
|
26
|
-
if (!arguments.length) {
|
|
27
|
-
return this._runnable;
|
|
28
|
-
}
|
|
29
|
-
this.test = this._runnable = runnable;
|
|
30
|
-
return this;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Set or get test timeout `ms`.
|
|
35
|
-
*
|
|
36
|
-
* @private
|
|
37
|
-
* @param {number} ms
|
|
38
|
-
* @return {Context} self
|
|
39
|
-
*/
|
|
40
|
-
Context.prototype.timeout = function(ms) {
|
|
41
|
-
if (!arguments.length) {
|
|
42
|
-
return this.runnable().timeout();
|
|
43
|
-
}
|
|
44
|
-
this.runnable().timeout(ms);
|
|
45
|
-
return this;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Set test timeout `enabled`.
|
|
50
|
-
*
|
|
51
|
-
* @private
|
|
52
|
-
* @param {boolean} enabled
|
|
53
|
-
* @return {Context} self
|
|
54
|
-
*/
|
|
55
|
-
Context.prototype.enableTimeouts = function(enabled) {
|
|
56
|
-
if (!arguments.length) {
|
|
57
|
-
return this.runnable().enableTimeouts();
|
|
58
|
-
}
|
|
59
|
-
this.runnable().enableTimeouts(enabled);
|
|
60
|
-
return this;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Set or get test slowness threshold `ms`.
|
|
65
|
-
*
|
|
66
|
-
* @private
|
|
67
|
-
* @param {number} ms
|
|
68
|
-
* @return {Context} self
|
|
69
|
-
*/
|
|
70
|
-
Context.prototype.slow = function(ms) {
|
|
71
|
-
if (!arguments.length) {
|
|
72
|
-
return this.runnable().slow();
|
|
73
|
-
}
|
|
74
|
-
this.runnable().slow(ms);
|
|
75
|
-
return this;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Mark a test as skipped.
|
|
80
|
-
*
|
|
81
|
-
* @private
|
|
82
|
-
* @throws Pending
|
|
83
|
-
*/
|
|
84
|
-
Context.prototype.skip = function() {
|
|
85
|
-
this.runnable().skip();
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Set or get a number of allowed retries on failed tests
|
|
90
|
-
*
|
|
91
|
-
* @private
|
|
92
|
-
* @param {number} n
|
|
93
|
-
* @return {Context} self
|
|
94
|
-
*/
|
|
95
|
-
Context.prototype.retries = function(n) {
|
|
96
|
-
if (!arguments.length) {
|
|
97
|
-
return this.runnable().retries();
|
|
98
|
-
}
|
|
99
|
-
this.runnable().retries(n);
|
|
100
|
-
return this;
|
|
101
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @module Context
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Expose `Context`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
module.exports = Context;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Initialize a new `Context`.
|
|
13
|
+
*
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
function Context() {}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Set or get the context `Runnable` to `runnable`.
|
|
20
|
+
*
|
|
21
|
+
* @private
|
|
22
|
+
* @param {Runnable} runnable
|
|
23
|
+
* @return {Context} context
|
|
24
|
+
*/
|
|
25
|
+
Context.prototype.runnable = function(runnable) {
|
|
26
|
+
if (!arguments.length) {
|
|
27
|
+
return this._runnable;
|
|
28
|
+
}
|
|
29
|
+
this.test = this._runnable = runnable;
|
|
30
|
+
return this;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Set or get test timeout `ms`.
|
|
35
|
+
*
|
|
36
|
+
* @private
|
|
37
|
+
* @param {number} ms
|
|
38
|
+
* @return {Context} self
|
|
39
|
+
*/
|
|
40
|
+
Context.prototype.timeout = function(ms) {
|
|
41
|
+
if (!arguments.length) {
|
|
42
|
+
return this.runnable().timeout();
|
|
43
|
+
}
|
|
44
|
+
this.runnable().timeout(ms);
|
|
45
|
+
return this;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Set test timeout `enabled`.
|
|
50
|
+
*
|
|
51
|
+
* @private
|
|
52
|
+
* @param {boolean} enabled
|
|
53
|
+
* @return {Context} self
|
|
54
|
+
*/
|
|
55
|
+
Context.prototype.enableTimeouts = function(enabled) {
|
|
56
|
+
if (!arguments.length) {
|
|
57
|
+
return this.runnable().enableTimeouts();
|
|
58
|
+
}
|
|
59
|
+
this.runnable().enableTimeouts(enabled);
|
|
60
|
+
return this;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Set or get test slowness threshold `ms`.
|
|
65
|
+
*
|
|
66
|
+
* @private
|
|
67
|
+
* @param {number} ms
|
|
68
|
+
* @return {Context} self
|
|
69
|
+
*/
|
|
70
|
+
Context.prototype.slow = function(ms) {
|
|
71
|
+
if (!arguments.length) {
|
|
72
|
+
return this.runnable().slow();
|
|
73
|
+
}
|
|
74
|
+
this.runnable().slow(ms);
|
|
75
|
+
return this;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Mark a test as skipped.
|
|
80
|
+
*
|
|
81
|
+
* @private
|
|
82
|
+
* @throws Pending
|
|
83
|
+
*/
|
|
84
|
+
Context.prototype.skip = function() {
|
|
85
|
+
this.runnable().skip();
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Set or get a number of allowed retries on failed tests
|
|
90
|
+
*
|
|
91
|
+
* @private
|
|
92
|
+
* @param {number} n
|
|
93
|
+
* @return {Context} self
|
|
94
|
+
*/
|
|
95
|
+
Context.prototype.retries = function(n) {
|
|
96
|
+
if (!arguments.length) {
|
|
97
|
+
return this.runnable().retries();
|
|
98
|
+
}
|
|
99
|
+
this.runnable().retries(n);
|
|
100
|
+
return this;
|
|
101
|
+
};
|
package/lib/errors.js
CHANGED
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* @module Errors
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Factory functions to create throwable error objects
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Creates an error object to be thrown when no files to be tested could be found using specified pattern.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
* @param {string} message - Error message to be displayed.
|
|
14
|
-
* @param {string} pattern - User-specified argument value.
|
|
15
|
-
* @returns {Error} instance detailing the error condition
|
|
16
|
-
*/
|
|
17
|
-
function createNoFilesMatchPatternError(message, pattern) {
|
|
18
|
-
var err = new Error(message);
|
|
19
|
-
err.code = 'ERR_MOCHA_NO_FILES_MATCH_PATTERN';
|
|
20
|
-
err.pattern = pattern;
|
|
21
|
-
return err;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Creates an error object to be thrown when the reporter specified in the options was not found.
|
|
26
|
-
*
|
|
27
|
-
* @public
|
|
28
|
-
* @param {string} message - Error message to be displayed.
|
|
29
|
-
* @param {string} reporter - User-specified reporter value.
|
|
30
|
-
* @returns {Error} instance detailing the error condition
|
|
31
|
-
*/
|
|
32
|
-
function createInvalidReporterError(message, reporter) {
|
|
33
|
-
var err = new TypeError(message);
|
|
34
|
-
err.code = 'ERR_MOCHA_INVALID_REPORTER';
|
|
35
|
-
err.reporter = reporter;
|
|
36
|
-
return err;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Creates an error object to be thrown when the interface specified in the options was not found.
|
|
41
|
-
*
|
|
42
|
-
* @public
|
|
43
|
-
* @param {string} message - Error message to be displayed.
|
|
44
|
-
* @param {string} ui - User-specified interface value.
|
|
45
|
-
* @returns {Error} instance detailing the error condition
|
|
46
|
-
*/
|
|
47
|
-
function createInvalidInterfaceError(message, ui) {
|
|
48
|
-
var err = new Error(message);
|
|
49
|
-
err.code = 'ERR_MOCHA_INVALID_INTERFACE';
|
|
50
|
-
err.interface = ui;
|
|
51
|
-
return err;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Creates an error object to be thrown when a behavior, option, or parameter is unsupported.
|
|
56
|
-
*
|
|
57
|
-
* @public
|
|
58
|
-
* @param {string} message - Error message to be displayed.
|
|
59
|
-
* @returns {Error} instance detailing the error condition
|
|
60
|
-
*/
|
|
61
|
-
function createUnsupportedError(message) {
|
|
62
|
-
var err = new Error(message);
|
|
63
|
-
err.code = 'ERR_MOCHA_UNSUPPORTED';
|
|
64
|
-
return err;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Creates an error object to be thrown when an argument is missing.
|
|
69
|
-
*
|
|
70
|
-
* @public
|
|
71
|
-
* @param {string} message - Error message to be displayed.
|
|
72
|
-
* @param {string} argument - Argument name.
|
|
73
|
-
* @param {string} expected - Expected argument datatype.
|
|
74
|
-
* @returns {Error} instance detailing the error condition
|
|
75
|
-
*/
|
|
76
|
-
function createMissingArgumentError(message, argument, expected) {
|
|
77
|
-
return createInvalidArgumentTypeError(message, argument, expected);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Creates an error object to be thrown when an argument did not use the supported type
|
|
82
|
-
*
|
|
83
|
-
* @public
|
|
84
|
-
* @param {string} message - Error message to be displayed.
|
|
85
|
-
* @param {string} argument - Argument name.
|
|
86
|
-
* @param {string} expected - Expected argument datatype.
|
|
87
|
-
* @returns {Error} instance detailing the error condition
|
|
88
|
-
*/
|
|
89
|
-
function createInvalidArgumentTypeError(message, argument, expected) {
|
|
90
|
-
var err = new TypeError(message);
|
|
91
|
-
err.code = 'ERR_MOCHA_INVALID_ARG_TYPE';
|
|
92
|
-
err.argument = argument;
|
|
93
|
-
err.expected = expected;
|
|
94
|
-
err.actual = typeof argument;
|
|
95
|
-
return err;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Creates an error object to be thrown when an argument did not use the supported value
|
|
100
|
-
*
|
|
101
|
-
* @public
|
|
102
|
-
* @param {string} message - Error message to be displayed.
|
|
103
|
-
* @param {string} argument - Argument name.
|
|
104
|
-
* @param {string} value - Argument value.
|
|
105
|
-
* @param {string} [reason] - Why value is invalid.
|
|
106
|
-
* @returns {Error} instance detailing the error condition
|
|
107
|
-
*/
|
|
108
|
-
function createInvalidArgumentValueError(message, argument, value, reason) {
|
|
109
|
-
var err = new TypeError(message);
|
|
110
|
-
err.code = 'ERR_MOCHA_INVALID_ARG_VALUE';
|
|
111
|
-
err.argument = argument;
|
|
112
|
-
err.value = value;
|
|
113
|
-
err.reason = typeof reason !== 'undefined' ? reason : 'is invalid';
|
|
114
|
-
return err;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Creates an error object to be thrown when an exception was caught, but the `Error` is falsy or undefined.
|
|
119
|
-
*
|
|
120
|
-
* @public
|
|
121
|
-
* @param {string} message - Error message to be displayed.
|
|
122
|
-
* @returns {Error} instance detailing the error condition
|
|
123
|
-
*/
|
|
124
|
-
function createInvalidExceptionError(message, value) {
|
|
125
|
-
var err = new Error(message);
|
|
126
|
-
err.code = 'ERR_MOCHA_INVALID_EXCEPTION';
|
|
127
|
-
err.valueType = typeof value;
|
|
128
|
-
err.value = value;
|
|
129
|
-
return err;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
module.exports = {
|
|
133
|
-
createInvalidArgumentTypeError: createInvalidArgumentTypeError,
|
|
134
|
-
createInvalidArgumentValueError: createInvalidArgumentValueError,
|
|
135
|
-
createInvalidExceptionError: createInvalidExceptionError,
|
|
136
|
-
createInvalidInterfaceError: createInvalidInterfaceError,
|
|
137
|
-
createInvalidReporterError: createInvalidReporterError,
|
|
138
|
-
createMissingArgumentError: createMissingArgumentError,
|
|
139
|
-
createNoFilesMatchPatternError: createNoFilesMatchPatternError,
|
|
140
|
-
createUnsupportedError: createUnsupportedError
|
|
141
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @module Errors
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Factory functions to create throwable error objects
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates an error object to be thrown when no files to be tested could be found using specified pattern.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
* @param {string} message - Error message to be displayed.
|
|
14
|
+
* @param {string} pattern - User-specified argument value.
|
|
15
|
+
* @returns {Error} instance detailing the error condition
|
|
16
|
+
*/
|
|
17
|
+
function createNoFilesMatchPatternError(message, pattern) {
|
|
18
|
+
var err = new Error(message);
|
|
19
|
+
err.code = 'ERR_MOCHA_NO_FILES_MATCH_PATTERN';
|
|
20
|
+
err.pattern = pattern;
|
|
21
|
+
return err;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Creates an error object to be thrown when the reporter specified in the options was not found.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
* @param {string} message - Error message to be displayed.
|
|
29
|
+
* @param {string} reporter - User-specified reporter value.
|
|
30
|
+
* @returns {Error} instance detailing the error condition
|
|
31
|
+
*/
|
|
32
|
+
function createInvalidReporterError(message, reporter) {
|
|
33
|
+
var err = new TypeError(message);
|
|
34
|
+
err.code = 'ERR_MOCHA_INVALID_REPORTER';
|
|
35
|
+
err.reporter = reporter;
|
|
36
|
+
return err;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates an error object to be thrown when the interface specified in the options was not found.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
* @param {string} message - Error message to be displayed.
|
|
44
|
+
* @param {string} ui - User-specified interface value.
|
|
45
|
+
* @returns {Error} instance detailing the error condition
|
|
46
|
+
*/
|
|
47
|
+
function createInvalidInterfaceError(message, ui) {
|
|
48
|
+
var err = new Error(message);
|
|
49
|
+
err.code = 'ERR_MOCHA_INVALID_INTERFACE';
|
|
50
|
+
err.interface = ui;
|
|
51
|
+
return err;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Creates an error object to be thrown when a behavior, option, or parameter is unsupported.
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
* @param {string} message - Error message to be displayed.
|
|
59
|
+
* @returns {Error} instance detailing the error condition
|
|
60
|
+
*/
|
|
61
|
+
function createUnsupportedError(message) {
|
|
62
|
+
var err = new Error(message);
|
|
63
|
+
err.code = 'ERR_MOCHA_UNSUPPORTED';
|
|
64
|
+
return err;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Creates an error object to be thrown when an argument is missing.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
* @param {string} message - Error message to be displayed.
|
|
72
|
+
* @param {string} argument - Argument name.
|
|
73
|
+
* @param {string} expected - Expected argument datatype.
|
|
74
|
+
* @returns {Error} instance detailing the error condition
|
|
75
|
+
*/
|
|
76
|
+
function createMissingArgumentError(message, argument, expected) {
|
|
77
|
+
return createInvalidArgumentTypeError(message, argument, expected);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Creates an error object to be thrown when an argument did not use the supported type
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
* @param {string} message - Error message to be displayed.
|
|
85
|
+
* @param {string} argument - Argument name.
|
|
86
|
+
* @param {string} expected - Expected argument datatype.
|
|
87
|
+
* @returns {Error} instance detailing the error condition
|
|
88
|
+
*/
|
|
89
|
+
function createInvalidArgumentTypeError(message, argument, expected) {
|
|
90
|
+
var err = new TypeError(message);
|
|
91
|
+
err.code = 'ERR_MOCHA_INVALID_ARG_TYPE';
|
|
92
|
+
err.argument = argument;
|
|
93
|
+
err.expected = expected;
|
|
94
|
+
err.actual = typeof argument;
|
|
95
|
+
return err;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates an error object to be thrown when an argument did not use the supported value
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
* @param {string} message - Error message to be displayed.
|
|
103
|
+
* @param {string} argument - Argument name.
|
|
104
|
+
* @param {string} value - Argument value.
|
|
105
|
+
* @param {string} [reason] - Why value is invalid.
|
|
106
|
+
* @returns {Error} instance detailing the error condition
|
|
107
|
+
*/
|
|
108
|
+
function createInvalidArgumentValueError(message, argument, value, reason) {
|
|
109
|
+
var err = new TypeError(message);
|
|
110
|
+
err.code = 'ERR_MOCHA_INVALID_ARG_VALUE';
|
|
111
|
+
err.argument = argument;
|
|
112
|
+
err.value = value;
|
|
113
|
+
err.reason = typeof reason !== 'undefined' ? reason : 'is invalid';
|
|
114
|
+
return err;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Creates an error object to be thrown when an exception was caught, but the `Error` is falsy or undefined.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
* @param {string} message - Error message to be displayed.
|
|
122
|
+
* @returns {Error} instance detailing the error condition
|
|
123
|
+
*/
|
|
124
|
+
function createInvalidExceptionError(message, value) {
|
|
125
|
+
var err = new Error(message);
|
|
126
|
+
err.code = 'ERR_MOCHA_INVALID_EXCEPTION';
|
|
127
|
+
err.valueType = typeof value;
|
|
128
|
+
err.value = value;
|
|
129
|
+
return err;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
module.exports = {
|
|
133
|
+
createInvalidArgumentTypeError: createInvalidArgumentTypeError,
|
|
134
|
+
createInvalidArgumentValueError: createInvalidArgumentValueError,
|
|
135
|
+
createInvalidExceptionError: createInvalidExceptionError,
|
|
136
|
+
createInvalidInterfaceError: createInvalidInterfaceError,
|
|
137
|
+
createInvalidReporterError: createInvalidReporterError,
|
|
138
|
+
createMissingArgumentError: createMissingArgumentError,
|
|
139
|
+
createNoFilesMatchPatternError: createNoFilesMatchPatternError,
|
|
140
|
+
createUnsupportedError: createUnsupportedError
|
|
141
|
+
};
|