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/bin/mocha
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* This tiny wrapper file checks for known node flags and appends them
|
|
5
7
|
* when found, before invoking the "real" _mocha(1) executable.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
|
-
var spawn = require('child_process').spawn
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
args = [path.join(__dirname, '_mocha')];
|
|
10
|
+
var spawn = require('child_process').spawn;
|
|
11
|
+
var path = require('path');
|
|
12
|
+
var getOptions = require('./options');
|
|
13
|
+
var args = [path.join(__dirname, '_mocha')];
|
|
13
14
|
|
|
14
15
|
// Load mocha.opts into process.argv
|
|
15
16
|
// Must be loaded here to handle node-specific options
|
|
16
17
|
getOptions();
|
|
17
18
|
|
|
18
|
-
process.argv.slice(2).forEach(function(arg){
|
|
19
|
+
process.argv.slice(2).forEach(function (arg) {
|
|
19
20
|
var flag = arg.split('=')[0];
|
|
20
21
|
|
|
21
22
|
switch (flag) {
|
|
@@ -26,6 +27,7 @@ process.argv.slice(2).forEach(function(arg){
|
|
|
26
27
|
case 'debug':
|
|
27
28
|
case '--debug':
|
|
28
29
|
case '--debug-brk':
|
|
30
|
+
case '--inspect':
|
|
29
31
|
args.unshift(arg);
|
|
30
32
|
args.push('--no-timeouts');
|
|
31
33
|
break;
|
|
@@ -46,19 +48,26 @@ process.argv.slice(2).forEach(function(arg){
|
|
|
46
48
|
args.unshift(arg);
|
|
47
49
|
break;
|
|
48
50
|
default:
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
else if (
|
|
52
|
-
|
|
53
|
-
else if (
|
|
54
|
-
|
|
51
|
+
if (arg.indexOf('--harmony') === 0) {
|
|
52
|
+
args.unshift(arg);
|
|
53
|
+
} else if (arg.indexOf('--trace') === 0) {
|
|
54
|
+
args.unshift(arg);
|
|
55
|
+
} else if (arg.indexOf('--icu-data-dir') === 0) {
|
|
56
|
+
args.unshift(arg);
|
|
57
|
+
} else if (arg.indexOf('--max-old-space-size') === 0) {
|
|
58
|
+
args.unshift(arg);
|
|
59
|
+
} else if (arg.indexOf('--preserve-symlinks') === 0) {
|
|
60
|
+
args.unshift(arg);
|
|
61
|
+
} else {
|
|
62
|
+
args.push(arg);
|
|
63
|
+
}
|
|
55
64
|
break;
|
|
56
65
|
}
|
|
57
66
|
});
|
|
58
67
|
|
|
59
68
|
var proc = spawn(process.execPath, args, { stdio: 'inherit' });
|
|
60
69
|
proc.on('exit', function (code, signal) {
|
|
61
|
-
process.on('exit', function(){
|
|
70
|
+
process.on('exit', function () {
|
|
62
71
|
if (signal) {
|
|
63
72
|
process.kill(process.pid, signal);
|
|
64
73
|
} else {
|
package/bin/options.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Dependencies.
|
|
3
5
|
*/
|
|
@@ -14,17 +16,17 @@ module.exports = getOptions;
|
|
|
14
16
|
* Get options.
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
|
-
function getOptions() {
|
|
18
|
-
var optsPath = process.argv.indexOf('--opts')
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
function getOptions () {
|
|
20
|
+
var optsPath = process.argv.indexOf('--opts') === -1
|
|
21
|
+
? 'test/mocha.opts'
|
|
22
|
+
: process.argv[process.argv.indexOf('--opts') + 1];
|
|
21
23
|
|
|
22
24
|
try {
|
|
23
25
|
var opts = fs.readFileSync(optsPath, 'utf8')
|
|
24
26
|
.replace(/\\\s/g, '%20')
|
|
25
27
|
.split(/\s/)
|
|
26
28
|
.filter(Boolean)
|
|
27
|
-
.map(function(value) {
|
|
29
|
+
.map(function (value) {
|
|
28
30
|
return value.replace(/%20/g, ' ');
|
|
29
31
|
});
|
|
30
32
|
|
package/browser-entry.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint no-unused-vars: off */
|
|
4
|
+
/* eslint-env commonjs */
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Shim process.stdout.
|
|
3
8
|
*/
|
|
@@ -33,15 +38,17 @@ var originalOnerrorHandler = global.onerror;
|
|
|
33
38
|
* Revert to original onerror handler if previously defined.
|
|
34
39
|
*/
|
|
35
40
|
|
|
36
|
-
process.removeListener = function(e, fn){
|
|
37
|
-
if ('uncaughtException'
|
|
41
|
+
process.removeListener = function (e, fn) {
|
|
42
|
+
if (e === 'uncaughtException') {
|
|
38
43
|
if (originalOnerrorHandler) {
|
|
39
44
|
global.onerror = originalOnerrorHandler;
|
|
40
45
|
} else {
|
|
41
|
-
global.onerror = function() {};
|
|
46
|
+
global.onerror = function () {};
|
|
42
47
|
}
|
|
43
48
|
var i = Mocha.utils.indexOf(uncaughtExceptionHandlers, fn);
|
|
44
|
-
if (i
|
|
49
|
+
if (i !== -1) {
|
|
50
|
+
uncaughtExceptionHandlers.splice(i, 1);
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
53
|
};
|
|
47
54
|
|
|
@@ -49,9 +56,9 @@ process.removeListener = function(e, fn){
|
|
|
49
56
|
* Implements uncaughtException listener.
|
|
50
57
|
*/
|
|
51
58
|
|
|
52
|
-
process.on = function(e, fn){
|
|
53
|
-
if ('uncaughtException'
|
|
54
|
-
global.onerror = function(err, url, line){
|
|
59
|
+
process.on = function (e, fn) {
|
|
60
|
+
if (e === 'uncaughtException') {
|
|
61
|
+
global.onerror = function (err, url, line) {
|
|
55
62
|
fn(new Error(err + ' (' + url + ':' + line + ')'));
|
|
56
63
|
return !mocha.allowUncaught;
|
|
57
64
|
};
|
|
@@ -64,10 +71,10 @@ process.on = function(e, fn){
|
|
|
64
71
|
// Ensure that this default UI does not expose its methods to the global scope.
|
|
65
72
|
mocha.suite.removeAllListeners('pre-require');
|
|
66
73
|
|
|
67
|
-
var immediateQueue = []
|
|
68
|
-
|
|
74
|
+
var immediateQueue = [];
|
|
75
|
+
var immediateTimeout;
|
|
69
76
|
|
|
70
|
-
function timeslice() {
|
|
77
|
+
function timeslice () {
|
|
71
78
|
var immediateStart = new Date().getTime();
|
|
72
79
|
while (immediateQueue.length && (new Date().getTime() - immediateStart) < 100) {
|
|
73
80
|
immediateQueue.shift()();
|
|
@@ -83,7 +90,7 @@ function timeslice() {
|
|
|
83
90
|
* High-performance override of Runner.immediately.
|
|
84
91
|
*/
|
|
85
92
|
|
|
86
|
-
Mocha.Runner.immediately = function(callback) {
|
|
93
|
+
Mocha.Runner.immediately = function (callback) {
|
|
87
94
|
immediateQueue.push(callback);
|
|
88
95
|
if (!immediateTimeout) {
|
|
89
96
|
immediateTimeout = setTimeout(timeslice, 0);
|
|
@@ -95,7 +102,7 @@ Mocha.Runner.immediately = function(callback) {
|
|
|
95
102
|
* This is useful when running tests in a browser because window.onerror will
|
|
96
103
|
* only receive the 'message' attribute of the Error.
|
|
97
104
|
*/
|
|
98
|
-
mocha.throwError = function(err) {
|
|
105
|
+
mocha.throwError = function (err) {
|
|
99
106
|
Mocha.utils.forEach(uncaughtExceptionHandlers, function (fn) {
|
|
100
107
|
fn(err);
|
|
101
108
|
});
|
|
@@ -107,7 +114,7 @@ mocha.throwError = function(err) {
|
|
|
107
114
|
* Normally this would happen in Mocha.prototype.loadFiles.
|
|
108
115
|
*/
|
|
109
116
|
|
|
110
|
-
mocha.ui = function(ui){
|
|
117
|
+
mocha.ui = function (ui) {
|
|
111
118
|
Mocha.prototype.ui.call(this, ui);
|
|
112
119
|
this.suite.emit('pre-require', global, null, this);
|
|
113
120
|
return this;
|
|
@@ -117,9 +124,15 @@ mocha.ui = function(ui){
|
|
|
117
124
|
* Setup mocha with the given setting options.
|
|
118
125
|
*/
|
|
119
126
|
|
|
120
|
-
mocha.setup = function(opts){
|
|
121
|
-
if (
|
|
122
|
-
|
|
127
|
+
mocha.setup = function (opts) {
|
|
128
|
+
if (typeof opts === 'string') {
|
|
129
|
+
opts = { ui: opts };
|
|
130
|
+
}
|
|
131
|
+
for (var opt in opts) {
|
|
132
|
+
if (opts.hasOwnProperty(opt)) {
|
|
133
|
+
this[opt](opts[opt]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
123
136
|
return this;
|
|
124
137
|
};
|
|
125
138
|
|
|
@@ -127,22 +140,30 @@ mocha.setup = function(opts){
|
|
|
127
140
|
* Run mocha, returning the Runner.
|
|
128
141
|
*/
|
|
129
142
|
|
|
130
|
-
mocha.run = function(fn){
|
|
143
|
+
mocha.run = function (fn) {
|
|
131
144
|
var options = mocha.options;
|
|
132
145
|
mocha.globals('location');
|
|
133
146
|
|
|
134
147
|
var query = Mocha.utils.parseQuery(global.location.search || '');
|
|
135
|
-
if (query.grep)
|
|
136
|
-
|
|
137
|
-
|
|
148
|
+
if (query.grep) {
|
|
149
|
+
mocha.grep(query.grep);
|
|
150
|
+
}
|
|
151
|
+
if (query.fgrep) {
|
|
152
|
+
mocha.fgrep(query.fgrep);
|
|
153
|
+
}
|
|
154
|
+
if (query.invert) {
|
|
155
|
+
mocha.invert();
|
|
156
|
+
}
|
|
138
157
|
|
|
139
|
-
return Mocha.prototype.run.call(mocha, function(err){
|
|
158
|
+
return Mocha.prototype.run.call(mocha, function (err) {
|
|
140
159
|
// The DOM Document is not available in Web Workers.
|
|
141
160
|
var document = global.document;
|
|
142
161
|
if (document && document.getElementById('mocha') && options.noHighlighting !== true) {
|
|
143
162
|
Mocha.utils.highlightTags('code');
|
|
144
163
|
}
|
|
145
|
-
if (fn)
|
|
164
|
+
if (fn) {
|
|
165
|
+
fn(err);
|
|
166
|
+
}
|
|
146
167
|
});
|
|
147
168
|
};
|
|
148
169
|
|
package/lib/browser/debug.js
CHANGED
package/lib/browser/events.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Module exports.
|
|
3
5
|
*/
|
|
@@ -16,7 +18,7 @@ var objToString = Object.prototype.toString;
|
|
|
16
18
|
* @param {*} val The value to test.
|
|
17
19
|
* @return {boolean} true if the value is an array, otherwise false.
|
|
18
20
|
*/
|
|
19
|
-
function isArray(val) {
|
|
21
|
+
function isArray (val) {
|
|
20
22
|
return objToString.call(val) === '[object Array]';
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -25,7 +27,7 @@ function isArray(val) {
|
|
|
25
27
|
*
|
|
26
28
|
* @api public
|
|
27
29
|
*/
|
|
28
|
-
function EventEmitter() {}
|
|
30
|
+
function EventEmitter () {}
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Add a listener.
|
|
@@ -35,7 +37,7 @@ function EventEmitter() {}
|
|
|
35
37
|
* @param {Function} fn Event handler.
|
|
36
38
|
* @return {EventEmitter} Emitter instance.
|
|
37
39
|
*/
|
|
38
|
-
EventEmitter.prototype.on = function(name, fn) {
|
|
40
|
+
EventEmitter.prototype.on = function (name, fn) {
|
|
39
41
|
if (!this.$events) {
|
|
40
42
|
this.$events = {};
|
|
41
43
|
}
|
|
@@ -61,10 +63,10 @@ EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
|
61
63
|
* @param {Function} fn Event handler.
|
|
62
64
|
* @return {EventEmitter} Emitter instance.
|
|
63
65
|
*/
|
|
64
|
-
EventEmitter.prototype.once = function(name, fn) {
|
|
66
|
+
EventEmitter.prototype.once = function (name, fn) {
|
|
65
67
|
var self = this;
|
|
66
68
|
|
|
67
|
-
function on() {
|
|
69
|
+
function on () {
|
|
68
70
|
self.removeListener(name, on);
|
|
69
71
|
fn.apply(this, arguments);
|
|
70
72
|
}
|
|
@@ -83,7 +85,7 @@ EventEmitter.prototype.once = function(name, fn) {
|
|
|
83
85
|
* @param {Function} fn Event handler.
|
|
84
86
|
* @return {EventEmitter} Emitter instance.
|
|
85
87
|
*/
|
|
86
|
-
EventEmitter.prototype.removeListener = function(name, fn) {
|
|
88
|
+
EventEmitter.prototype.removeListener = function (name, fn) {
|
|
87
89
|
if (this.$events && this.$events[name]) {
|
|
88
90
|
var list = this.$events[name];
|
|
89
91
|
|
|
@@ -121,7 +123,7 @@ EventEmitter.prototype.removeListener = function(name, fn) {
|
|
|
121
123
|
* @param {string} name Event name.
|
|
122
124
|
* @return {EventEmitter} Emitter instance.
|
|
123
125
|
*/
|
|
124
|
-
EventEmitter.prototype.removeAllListeners = function(name) {
|
|
126
|
+
EventEmitter.prototype.removeAllListeners = function (name) {
|
|
125
127
|
if (name === undefined) {
|
|
126
128
|
this.$events = {};
|
|
127
129
|
return this;
|
|
@@ -141,7 +143,7 @@ EventEmitter.prototype.removeAllListeners = function(name) {
|
|
|
141
143
|
* @param {string} name Event name.
|
|
142
144
|
* @return {EventEmitter} Emitter instance.
|
|
143
145
|
*/
|
|
144
|
-
EventEmitter.prototype.listeners = function(name) {
|
|
146
|
+
EventEmitter.prototype.listeners = function (name) {
|
|
145
147
|
if (!this.$events) {
|
|
146
148
|
this.$events = {};
|
|
147
149
|
}
|
|
@@ -164,7 +166,7 @@ EventEmitter.prototype.listeners = function(name) {
|
|
|
164
166
|
* @param {string} name Event name.
|
|
165
167
|
* @return {boolean} true if at least one handler was invoked, else false.
|
|
166
168
|
*/
|
|
167
|
-
EventEmitter.prototype.emit = function(name) {
|
|
169
|
+
EventEmitter.prototype.emit = function (name) {
|
|
168
170
|
if (!this.$events) {
|
|
169
171
|
return false;
|
|
170
172
|
}
|
package/lib/browser/progress.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Expose `Progress`.
|
|
3
5
|
*/
|
|
@@ -7,7 +9,7 @@ module.exports = Progress;
|
|
|
7
9
|
/**
|
|
8
10
|
* Initialize a new `Progress` indicator.
|
|
9
11
|
*/
|
|
10
|
-
function Progress() {
|
|
12
|
+
function Progress () {
|
|
11
13
|
this.percent = 0;
|
|
12
14
|
this.size(0);
|
|
13
15
|
this.fontSize(11);
|
|
@@ -21,7 +23,7 @@ function Progress() {
|
|
|
21
23
|
* @param {number} size
|
|
22
24
|
* @return {Progress} Progress instance.
|
|
23
25
|
*/
|
|
24
|
-
Progress.prototype.size = function(size) {
|
|
26
|
+
Progress.prototype.size = function (size) {
|
|
25
27
|
this._size = size;
|
|
26
28
|
return this;
|
|
27
29
|
};
|
|
@@ -33,7 +35,7 @@ Progress.prototype.size = function(size) {
|
|
|
33
35
|
* @param {string} text
|
|
34
36
|
* @return {Progress} Progress instance.
|
|
35
37
|
*/
|
|
36
|
-
Progress.prototype.text = function(text) {
|
|
38
|
+
Progress.prototype.text = function (text) {
|
|
37
39
|
this._text = text;
|
|
38
40
|
return this;
|
|
39
41
|
};
|
|
@@ -45,7 +47,7 @@ Progress.prototype.text = function(text) {
|
|
|
45
47
|
* @param {number} size
|
|
46
48
|
* @return {Progress} Progress instance.
|
|
47
49
|
*/
|
|
48
|
-
Progress.prototype.fontSize = function(size) {
|
|
50
|
+
Progress.prototype.fontSize = function (size) {
|
|
49
51
|
this._fontSize = size;
|
|
50
52
|
return this;
|
|
51
53
|
};
|
|
@@ -56,7 +58,7 @@ Progress.prototype.fontSize = function(size) {
|
|
|
56
58
|
* @param {string} family
|
|
57
59
|
* @return {Progress} Progress instance.
|
|
58
60
|
*/
|
|
59
|
-
Progress.prototype.font = function(family) {
|
|
61
|
+
Progress.prototype.font = function (family) {
|
|
60
62
|
this._font = family;
|
|
61
63
|
return this;
|
|
62
64
|
};
|
|
@@ -67,7 +69,7 @@ Progress.prototype.font = function(family) {
|
|
|
67
69
|
* @param {number} n
|
|
68
70
|
* @return {Progress} Progress instance.
|
|
69
71
|
*/
|
|
70
|
-
Progress.prototype.update = function(n) {
|
|
72
|
+
Progress.prototype.update = function (n) {
|
|
71
73
|
this.percent = n;
|
|
72
74
|
return this;
|
|
73
75
|
};
|
|
@@ -78,7 +80,7 @@ Progress.prototype.update = function(n) {
|
|
|
78
80
|
* @param {CanvasRenderingContext2d} ctx
|
|
79
81
|
* @return {Progress} Progress instance.
|
|
80
82
|
*/
|
|
81
|
-
Progress.prototype.draw = function(ctx) {
|
|
83
|
+
Progress.prototype.draw = function (ctx) {
|
|
82
84
|
try {
|
|
83
85
|
var percent = Math.min(this.percent, 100);
|
|
84
86
|
var size = this._size;
|
package/lib/browser/tty.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
exports.isatty = function isatty () {
|
|
2
4
|
return true;
|
|
3
5
|
};
|
|
4
6
|
|
|
5
|
-
exports.getWindowSize = function getWindowSize() {
|
|
7
|
+
exports.getWindowSize = function getWindowSize () {
|
|
6
8
|
if ('innerHeight' in global) {
|
|
7
9
|
return [global.innerHeight, global.innerWidth];
|
|
8
10
|
}
|
package/lib/context.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Module dependencies.
|
|
3
5
|
*/
|
|
@@ -15,7 +17,7 @@ module.exports = Context;
|
|
|
15
17
|
*
|
|
16
18
|
* @api private
|
|
17
19
|
*/
|
|
18
|
-
function Context() {}
|
|
20
|
+
function Context () {}
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Set or get the context `Runnable` to `runnable`.
|
|
@@ -24,7 +26,7 @@ function Context() {}
|
|
|
24
26
|
* @param {Runnable} runnable
|
|
25
27
|
* @return {Context}
|
|
26
28
|
*/
|
|
27
|
-
Context.prototype.runnable = function(runnable) {
|
|
29
|
+
Context.prototype.runnable = function (runnable) {
|
|
28
30
|
if (!arguments.length) {
|
|
29
31
|
return this._runnable;
|
|
30
32
|
}
|
|
@@ -39,7 +41,7 @@ Context.prototype.runnable = function(runnable) {
|
|
|
39
41
|
* @param {number} ms
|
|
40
42
|
* @return {Context} self
|
|
41
43
|
*/
|
|
42
|
-
Context.prototype.timeout = function(ms) {
|
|
44
|
+
Context.prototype.timeout = function (ms) {
|
|
43
45
|
if (!arguments.length) {
|
|
44
46
|
return this.runnable().timeout();
|
|
45
47
|
}
|
|
@@ -54,7 +56,7 @@ Context.prototype.timeout = function(ms) {
|
|
|
54
56
|
* @param {boolean} enabled
|
|
55
57
|
* @return {Context} self
|
|
56
58
|
*/
|
|
57
|
-
Context.prototype.enableTimeouts = function(enabled) {
|
|
59
|
+
Context.prototype.enableTimeouts = function (enabled) {
|
|
58
60
|
this.runnable().enableTimeouts(enabled);
|
|
59
61
|
return this;
|
|
60
62
|
};
|
|
@@ -66,7 +68,7 @@ Context.prototype.enableTimeouts = function(enabled) {
|
|
|
66
68
|
* @param {number} ms
|
|
67
69
|
* @return {Context} self
|
|
68
70
|
*/
|
|
69
|
-
Context.prototype.slow = function(ms) {
|
|
71
|
+
Context.prototype.slow = function (ms) {
|
|
70
72
|
this.runnable().slow(ms);
|
|
71
73
|
return this;
|
|
72
74
|
};
|
|
@@ -77,7 +79,7 @@ Context.prototype.slow = function(ms) {
|
|
|
77
79
|
* @api private
|
|
78
80
|
* @return {Context} self
|
|
79
81
|
*/
|
|
80
|
-
Context.prototype.skip = function() {
|
|
82
|
+
Context.prototype.skip = function () {
|
|
81
83
|
this.runnable().skip();
|
|
82
84
|
return this;
|
|
83
85
|
};
|
|
@@ -89,7 +91,7 @@ Context.prototype.skip = function() {
|
|
|
89
91
|
* @param {number} n
|
|
90
92
|
* @return {Context} self
|
|
91
93
|
*/
|
|
92
|
-
Context.prototype.retries = function(n) {
|
|
94
|
+
Context.prototype.retries = function (n) {
|
|
93
95
|
if (!arguments.length) {
|
|
94
96
|
return this.runnable().retries();
|
|
95
97
|
}
|
|
@@ -103,8 +105,8 @@ Context.prototype.retries = function(n) {
|
|
|
103
105
|
* @api private
|
|
104
106
|
* @return {string}
|
|
105
107
|
*/
|
|
106
|
-
Context.prototype.inspect = function() {
|
|
107
|
-
return JSON.stringify(this, function(key, val) {
|
|
108
|
+
Context.prototype.inspect = function () {
|
|
109
|
+
return JSON.stringify(this, function (key, val) {
|
|
108
110
|
return key === 'runnable' || key === 'test' ? undefined : val;
|
|
109
111
|
}, 2);
|
|
110
112
|
};
|
package/lib/hook.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Module dependencies.
|
|
3
5
|
*/
|
|
@@ -18,7 +20,7 @@ module.exports = Hook;
|
|
|
18
20
|
* @param {Function} fn
|
|
19
21
|
* @api private
|
|
20
22
|
*/
|
|
21
|
-
function Hook(title, fn) {
|
|
23
|
+
function Hook (title, fn) {
|
|
22
24
|
Runnable.call(this, title, fn);
|
|
23
25
|
this.type = 'hook';
|
|
24
26
|
}
|
|
@@ -35,7 +37,7 @@ inherits(Hook, Runnable);
|
|
|
35
37
|
* @return {Error}
|
|
36
38
|
* @api public
|
|
37
39
|
*/
|
|
38
|
-
Hook.prototype.error = function(err) {
|
|
40
|
+
Hook.prototype.error = function (err) {
|
|
39
41
|
if (!arguments.length) {
|
|
40
42
|
err = this._error;
|
|
41
43
|
this._error = null;
|
package/lib/interfaces/bdd.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Module dependencies.
|
|
3
5
|
*/
|
|
@@ -21,10 +23,10 @@ var Test = require('../test');
|
|
|
21
23
|
*
|
|
22
24
|
* @param {Suite} suite Root suite.
|
|
23
25
|
*/
|
|
24
|
-
module.exports = function(suite) {
|
|
26
|
+
module.exports = function (suite) {
|
|
25
27
|
var suites = [suite];
|
|
26
28
|
|
|
27
|
-
suite.on('pre-require', function(context, file, mocha) {
|
|
29
|
+
suite.on('pre-require', function (context, file, mocha) {
|
|
28
30
|
var common = require('./common')(suites, context, mocha);
|
|
29
31
|
|
|
30
32
|
context.before = common.before;
|
|
@@ -38,7 +40,7 @@ module.exports = function(suite) {
|
|
|
38
40
|
* and/or tests.
|
|
39
41
|
*/
|
|
40
42
|
|
|
41
|
-
context.describe = context.context = function(title, fn) {
|
|
43
|
+
context.describe = context.context = function (title, fn) {
|
|
42
44
|
return common.suite.create({
|
|
43
45
|
title: title,
|
|
44
46
|
file: file,
|
|
@@ -50,7 +52,7 @@ module.exports = function(suite) {
|
|
|
50
52
|
* Pending describe.
|
|
51
53
|
*/
|
|
52
54
|
|
|
53
|
-
context.xdescribe = context.xcontext = context.describe.skip = function(title, fn) {
|
|
55
|
+
context.xdescribe = context.xcontext = context.describe.skip = function (title, fn) {
|
|
54
56
|
return common.suite.skip({
|
|
55
57
|
title: title,
|
|
56
58
|
file: file,
|
|
@@ -62,7 +64,7 @@ module.exports = function(suite) {
|
|
|
62
64
|
* Exclusive suite.
|
|
63
65
|
*/
|
|
64
66
|
|
|
65
|
-
context.describe.only = function(title, fn) {
|
|
67
|
+
context.describe.only = function (title, fn) {
|
|
66
68
|
return common.suite.only({
|
|
67
69
|
title: title,
|
|
68
70
|
file: file,
|
|
@@ -76,7 +78,7 @@ module.exports = function(suite) {
|
|
|
76
78
|
* acting as a thunk.
|
|
77
79
|
*/
|
|
78
80
|
|
|
79
|
-
context.it = context.specify = function(title, fn) {
|
|
81
|
+
context.it = context.specify = function (title, fn) {
|
|
80
82
|
var suite = suites[0];
|
|
81
83
|
if (suite.isPending()) {
|
|
82
84
|
fn = null;
|
|
@@ -91,7 +93,7 @@ module.exports = function(suite) {
|
|
|
91
93
|
* Exclusive test-case.
|
|
92
94
|
*/
|
|
93
95
|
|
|
94
|
-
context.it.only = function(title, fn) {
|
|
96
|
+
context.it.only = function (title, fn) {
|
|
95
97
|
return common.test.only(mocha, context.it(title, fn));
|
|
96
98
|
};
|
|
97
99
|
|
|
@@ -99,14 +101,14 @@ module.exports = function(suite) {
|
|
|
99
101
|
* Pending test case.
|
|
100
102
|
*/
|
|
101
103
|
|
|
102
|
-
context.xit = context.xspecify = context.it.skip = function(title) {
|
|
104
|
+
context.xit = context.xspecify = context.it.skip = function (title) {
|
|
103
105
|
context.it(title);
|
|
104
106
|
};
|
|
105
107
|
|
|
106
108
|
/**
|
|
107
109
|
* Number of attempts to retry.
|
|
108
110
|
*/
|
|
109
|
-
context.it.retries = function(n) {
|
|
111
|
+
context.it.retries = function (n) {
|
|
110
112
|
context.retries(n);
|
|
111
113
|
};
|
|
112
114
|
});
|