mocha 2.2.0 → 2.2.5

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/README.md CHANGED
@@ -4,219 +4,6 @@
4
4
 
5
5
  Mocha is a simple, flexible, fun JavaScript test framework for node.js and the browser. For more information view the [documentation](http://mochajs.org).
6
6
 
7
- ## Contributors
8
-
9
- ```
10
- project : mocha
11
- repo age : 3 years, 4 months
12
- active : 509 days
13
- commits : 1575
14
- files : 153
15
- authors :
16
- 977 TJ Holowaychuk 62.0%
17
- 132 Travis Jeffery 8.4%
18
- 63 Christopher Hiller 4.0%
19
- 31 Guillermo Rauch 2.0%
20
- 27 Joshua Appelman 1.7%
21
- 13 Attila Domokos 0.8%
22
- 10 John Firebaugh 0.6%
23
- 8 Nathan Rajlich 0.5%
24
- 8 Jo Liss 0.5%
25
- 6 Mike Pennisi 0.4%
26
- 6 Brendan Nee 0.4%
27
- 6 James Carr 0.4%
28
- 5 Aaron Heckmann 0.3%
29
- 5 Raynos 0.3%
30
- 5 Ryunosuke SATO 0.3%
31
- 4 hokaccha 0.3%
32
- 4 Jonathan Ong 0.3%
33
- 4 Joshua Krall 0.3%
34
- 4 Domenic Denicola 0.3%
35
- 4 Forbes Lindesay 0.3%
36
- 4 Xavier Antoviaque 0.3%
37
- 4 David da Silva 0.3%
38
- 3 Ariel Mashraki 0.2%
39
- 3 Ben Bradley 0.2%
40
- 3 Merrick Christensen 0.2%
41
- 3 Andreas Lind Petersen 0.2%
42
- 3 Nathan Bowser 0.2%
43
- 3 Cory Thomas 0.2%
44
- 3 Benjie Gillam 0.2%
45
- 3 Wil Moore III 0.2%
46
- 3 Ben Lindsey 0.2%
47
- 3 Tyson Tate 0.2%
48
- 3 Paul Miller 0.2%
49
- 3 eiji.ienaga 0.2%
50
- 3 Mathieu Desvé 0.2%
51
- 3 Jesse Dailey 0.2%
52
- 3 fool2fish 0.2%
53
- 3 Fredrik Enestad 0.2%
54
- 3 Sindre Sorhus 0.2%
55
- 3 Valentin Agachi 0.2%
56
- 2 jsdevel 0.1%
57
- 2 Arian Stolwijk 0.1%
58
- 2 Juzer Ali 0.1%
59
- 2 David Henderson 0.1%
60
- 2 Justin DuJardin 0.1%
61
- 2 Paul Armstrong 0.1%
62
- 2 Pete Hawkins 0.1%
63
- 2 Jonas Westerlund 0.1%
64
- 2 Quang Van 0.1%
65
- 2 Simon Gaeremynck 0.1%
66
- 2 travis jeffery 0.1%
67
- 2 Dominique Quatravaux 0.1%
68
- 2 Jacob Wejendorp 0.1%
69
- 2 Shawn Krisman 0.1%
70
- 2 FARKAS Máté 0.1%
71
- 2 Konstantin Käfer 0.1%
72
- 2 Timo Tijhof 0.1%
73
- 2 Sean Lang 0.1%
74
- 2 Quanlong He 0.1%
75
- 2 Glen Mailer 0.1%
76
- 2 Alexander Early 0.1%
77
- 2 Ian Storm Taylor 0.1%
78
- 2 Brian Beck 0.1%
79
- 2 Michael Riley 0.1%
80
- 2 Michael Schoonmaker 0.1%
81
- 2 domenic 0.1%
82
- 2 fcrisci 0.1%
83
- 2 Buck Doyle 0.1%
84
- 2 Nathan Alderson 0.1%
85
- 1 Mal Graty 0.1%
86
- 1 Marc Kuo 0.1%
87
- 1 Matija Marohnić 0.1%
88
- 1 Matt Robenolt 0.1%
89
- 1 Matt Smith 0.1%
90
- 1 Matthew Shanley 0.1%
91
- 1 Mattias Tidlund 0.1%
92
- 1 Michael Jackson 0.1%
93
- 1 Michael Olson 0.1%
94
- 1 Michal Charemza 0.1%
95
- 1 Nathan Black 0.1%
96
- 1 Nick Fitzgerald 0.1%
97
- 1 Noshir Patel 0.1%
98
- 1 Panu Horsmalahti 0.1%
99
- 1 Phil Sung 0.1%
100
- 1 R56 0.1%
101
- 1 Refael Ackermann 0.1%
102
- 1 Richard Dingwall 0.1%
103
- 1 Richard Knop 0.1%
104
- 1 Rob Wu 0.1%
105
- 1 Romain Prieto 0.1%
106
- 1 Roman Neuhauser 0.1%
107
- 1 Roman Shtylman 0.1%
108
- 1 Russ Bradberry 0.1%
109
- 1 Russell Munson 0.1%
110
- 1 Rustem Mustafin 0.1%
111
- 1 Salehen Shovon Rahman 0.1%
112
- 1 Sasha Koss 0.1%
113
- 1 Seiya Konno 0.1%
114
- 1 Shaine Hatch 0.1%
115
- 1 Simon Goumaz 0.1%
116
- 1 Standa Opichal 0.1%
117
- 1 Stephen Mathieson 0.1%
118
- 1 Steve Mason 0.1%
119
- 1 Tapiwa Kelvin 0.1%
120
- 1 Teddy Zeenny 0.1%
121
- 1 Tim Ehat 0.1%
122
- 1 Vadim Nikitin 0.1%
123
- 1 Victor Costan 0.1%
124
- 1 Will Langstroth 0.1%
125
- 1 Yanis Wang 0.1%
126
- 1 Yuest Wang 0.1%
127
- 1 Zsolt Takács 0.1%
128
- 1 abrkn 0.1%
129
- 1 airportyh 0.1%
130
- 1 badunk 0.1%
131
- 1 claudyus 0.1%
132
- 1 dasilvacontin 0.1%
133
- 1 fengmk2 0.1%
134
- 1 gaye 0.1%
135
- 1 grasGendarme 0.1%
136
- 1 lakmeer 0.1%
137
- 1 lodr 0.1%
138
- 1 mrShturman 0.1%
139
- 1 nishigori 0.1%
140
- 1 omardelarosa 0.1%
141
- 1 qiuzuhui 0.1%
142
- 1 samuel goldszmidt 0.1%
143
- 1 sebv 0.1%
144
- 1 startswithaj 0.1%
145
- 1 tgautier@yahoo.com 0.1%
146
- 1 traleig1 0.1%
147
- 1 vlad 0.1%
148
- 1 yuitest 0.1%
149
- 1 zhiyelee 0.1%
150
- 1 Adam Crabtree 0.1%
151
- 1 Andreas Brekken 0.1%
152
- 1 Andrew Nesbitt 0.1%
153
- 1 Andrey Popp 0.1%
154
- 1 Arnaud Brousseau 0.1%
155
- 1 Atsuya Takagi 0.1%
156
- 1 Austin Birch 0.1%
157
- 1 Ben Noordhuis 0.1%
158
- 1 Bjørge Næss 0.1%
159
- 1 Brian Lalor 0.1%
160
- 1 Brian M. Carlson 0.1%
161
- 1 Brian Moore 0.1%
162
- 1 Bryan Donovan 0.1%
163
- 1 C. Scott Ananian 0.1%
164
- 1 Casey Foster 0.1%
165
- 1 ChrisWren 0.1%
166
- 1 Connor Dunn 0.1%
167
- 1 Corey Butler 0.1%
168
- 1 Daniel Stockman 0.1%
169
- 1 Dave McKenna 0.1%
170
- 1 Denis Bardadym 0.1%
171
- 1 Devin Weaver 0.1%
172
- 1 Di Wu 0.1%
173
- 1 Diogo Monteiro 0.1%
174
- 1 Dmitry Shirokov 0.1%
175
- 1 Dr. Travis Jeffery 0.1%
176
- 1 Fedor Indutny 0.1%
177
- 1 Florian Margaine 0.1%
178
- 1 Frederico Silva 0.1%
179
- 1 Fredrik Lindin 0.1%
180
- 1 Gareth Aye 0.1%
181
- 1 Gareth Murphy 0.1%
182
- 1 Gavin Mogan 0.1%
183
- 1 Giovanni Bassi 0.1%
184
- 1 Glen Huang 0.1%
185
- 1 Greg Perkins 0.1%
186
- 1 Harish 0.1%
187
- 1 Harry Brundage 0.1%
188
- 1 Herman Junge 0.1%
189
- 1 Ian Young 0.1%
190
- 1 Ivan 0.1%
191
- 1 JP Bochi 0.1%
192
- 1 Jaakko Salonen 0.1%
193
- 1 Jakub Nešetřil 0.1%
194
- 1 James Bowes 0.1%
195
- 1 James Lal 0.1%
196
- 1 Jan Kopriva 0.1%
197
- 1 Jason Barry 0.1%
198
- 1 Javier Aranda 0.1%
199
- 1 Jean Ponchon 0.1%
200
- 1 Jeff Kunkle 0.1%
201
- 1 Jeremy Martin 0.1%
202
- 1 Jimmy Cuadra 0.1%
203
- 1 John Doty 0.1%
204
- 1 Jonathan Creamer 0.1%
205
- 1 Jonathan Park 0.1%
206
- 1 Jussi Virtanen 0.1%
207
- 1 Katie Gengler 0.1%
208
- 1 Kazuhito Hokamura 0.1%
209
- 1 Kent C. Dodds 0.1%
210
- 1 Kevin Conway 0.1%
211
- 1 Kirill Korolyov 0.1%
212
- 1 Koen Punt 0.1%
213
- 1 Laszlo Bacsi 0.1%
214
- 1 Liam Newman 0.1%
215
- 1 Linus Unnebäck 0.1%
216
- 1 László Bácsi 0.1%
217
- 1 Maciej Małecki 0.1%
218
- ```
219
-
220
7
  ## Links
221
8
 
222
9
  - [Google Group](http://groups.google.com/group/mochajs)
package/bin/_mocha CHANGED
@@ -1,17 +1,20 @@
1
+ #!/usr/bin/env node
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
4
6
 
5
- var program = require('commander')
6
- , path = require('path')
7
- , fs = require('fs')
8
- , resolve = path.resolve
9
- , exists = fs.existsSync || path.existsSync
10
- , Mocha = require('../')
11
- , utils = Mocha.utils
12
- , join = path.join
13
- , cwd = process.cwd()
14
- , mocha = new Mocha;
7
+ var program = require('commander'),
8
+ path = require('path'),
9
+ fs = require('fs'),
10
+ resolve = path.resolve,
11
+ exists = fs.existsSync || path.existsSync,
12
+ Mocha = require('../'),
13
+ utils = Mocha.utils,
14
+ join = path.join,
15
+ cwd = process.cwd(),
16
+ getOptions = require('./options'),
17
+ mocha = new Mocha;
15
18
 
16
19
  /**
17
20
  * Save timer references to avoid Sinon interfering (see GH-237).
@@ -74,16 +77,19 @@ program
74
77
  .option('-u, --ui <name>', 'specify user-interface (bdd|tdd|exports)', 'bdd')
75
78
  .option('-w, --watch', 'watch files for changes')
76
79
  .option('--check-leaks', 'check for global variable leaks')
80
+ .option('--full-trace', 'display the full stack trace')
77
81
  .option('--compilers <ext>:<module>,...', 'use the given module(s) to compile files', list, [])
78
82
  .option('--debug-brk', "enable node's debugger breaking on the first line")
79
83
  .option('--globals <names>', 'allow the given comma-delimited global [names]', list, [])
80
84
  .option('--harmony', 'enable all harmony features (except typeof)')
85
+ .option('--es_staging', 'enable all staged features')
81
86
  .option('--harmony-collections', 'enable harmony collections (sets, maps, and weak maps)')
82
87
  .option('--harmony-generators', 'enable harmony generators')
83
88
  .option('--harmony-proxies', 'enable harmony proxies')
84
89
  .option('--harmony_shipping', 'enable all shipped harmony fetaures (iojs)')
85
90
  .option('--harmony_arrow_functions', 'enable "harmony arrow functions" (iojs)')
86
91
  .option('--harmony_proxies', 'enable "harmony proxies" (iojs)')
92
+ .option('--harmony_classes', 'enable "harmony classes" (iojs)')
87
93
  .option('--inline-diffs', 'display actual/expected differences inline within each string')
88
94
  .option('--interfaces', 'display available interfaces')
89
95
  .option('--no-deprecation', 'silence deprecation warnings')
@@ -170,26 +176,9 @@ program.on('require', function(mod){
170
176
  requires.push(mod);
171
177
  });
172
178
 
173
- // --opts
179
+ // load mocha.opts into process.argv
174
180
 
175
- var optsPath = process.argv.indexOf('--opts') !== -1
176
- ? process.argv[process.argv.indexOf('--opts') + 1]
177
- : 'test/mocha.opts';
178
-
179
- try {
180
- var opts = fs.readFileSync(optsPath, 'utf8')
181
- .trim()
182
- .split(/\s+/)
183
- .filter(function(value) {
184
- return value ? true : false;
185
- });
186
-
187
- process.argv = process.argv
188
- .slice(0, 2)
189
- .concat(opts.concat(process.argv.slice(2)));
190
- } catch (err) {
191
- // ignore
192
- }
181
+ getOptions();
193
182
 
194
183
  // parse args
195
184
 
@@ -279,6 +268,10 @@ if (program.invert) mocha.invert();
279
268
 
280
269
  if (program.checkLeaks) mocha.checkLeaks();
281
270
 
271
+ // --stack-trace
272
+
273
+ if(program.fullTrace) mocha.fullTrace();
274
+
282
275
  // --growl
283
276
 
284
277
  if (program.growl) mocha.growl();
package/bin/mocha CHANGED
@@ -7,7 +7,13 @@
7
7
 
8
8
  var spawn = require('child_process').spawn,
9
9
  path = require('path'),
10
- args = [process.execPath, path.join(__dirname, '_mocha')];
10
+ fs = require('fs'),
11
+ args = [path.join(__dirname, '_mocha')],
12
+ getOptions = require('./options');
13
+
14
+ // load mocha.opts into process.argv
15
+
16
+ getOptions();
11
17
 
12
18
  process.argv.slice(2).forEach(function(arg){
13
19
  var flag = arg.split('=')[0];
@@ -29,16 +35,19 @@ process.argv.slice(2).forEach(function(arg){
29
35
  break;
30
36
  case '--gc-global':
31
37
  case '--harmony':
38
+ case '--es_staging':
32
39
  case '--harmony-proxies':
33
40
  case '--harmony-collections':
34
41
  case '--harmony-generators':
35
42
  case '--harmony_shipping':
36
43
  case '--harmony_arrow_functions':
37
44
  case '--harmony_proxies':
45
+ case '--harmony_classes':
38
46
  case '--no-deprecation':
39
47
  case '--prof':
40
48
  case '--throw-deprecation':
41
49
  case '--trace-deprecation':
50
+ case '--allow-natives-syntax':
42
51
  args.unshift(arg);
43
52
  break;
44
53
  default:
@@ -48,7 +57,7 @@ process.argv.slice(2).forEach(function(arg){
48
57
  }
49
58
  });
50
59
 
51
- var proc = spawn(args[0], args.slice(1), { stdio: 'inherit' });
60
+ var proc = spawn(process.execPath, args, { stdio: 'inherit' });
52
61
  proc.on('exit', function (code, signal) {
53
62
  process.on('exit', function(){
54
63
  if (signal) {
package/bin/options.js ADDED
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Dependencies.
3
+ */
4
+
5
+ var fs = require('fs');
6
+
7
+ /**
8
+ * Export `getOptions`.
9
+ */
10
+
11
+ module.exports = getOptions;
12
+
13
+ /**
14
+ * Get options.
15
+ */
16
+
17
+ function getOptions() {
18
+ var optsPath = process.argv.indexOf('--opts') !== -1
19
+ ? process.argv[process.argv.indexOf('--opts') + 1]
20
+ : 'test/mocha.opts';
21
+
22
+ try {
23
+ var opts = fs.readFileSync(optsPath, 'utf8')
24
+ .trim()
25
+ .split(/\s+/)
26
+ .filter(function(value) {
27
+ return value ? true : false;
28
+ });
29
+
30
+ process.argv = process.argv
31
+ .slice(0, 2)
32
+ .concat(opts.concat(process.argv.slice(2)));
33
+ } catch (err) {
34
+ // ignore
35
+ }
36
+ }
package/lib/mocha.js CHANGED
@@ -66,6 +66,7 @@ function image(name) {
66
66
  * - `bail` bail on the first test failure
67
67
  * - `slow` milliseconds to wait before considering a test slow
68
68
  * - `ignoreLeaks` ignore global leaks
69
+ * - `fullTrace` display the full stack-trace on failing
69
70
  * - `grep` string or regexp to filter tests with
70
71
  *
71
72
  * @param {Object} options
@@ -83,7 +84,7 @@ function Mocha(options) {
83
84
  this.bail(options.bail);
84
85
  this.reporter(options.reporter, options.reporterOptions);
85
86
  if (null != options.timeout) this.timeout(options.timeout);
86
- this.useColors(options.useColors)
87
+ this.useColors(options.useColors);
87
88
  if (options.enableTimeouts !== null) this.enableTimeouts(options.enableTimeouts);
88
89
  if (options.slow) this.slow(options.slow);
89
90
 
@@ -142,8 +143,12 @@ Mocha.prototype.reporter = function(reporter, reporterOptions){
142
143
  } else {
143
144
  reporter = reporter || 'spec';
144
145
  var _reporter;
145
- try { _reporter = require('./reporters/' + reporter); } catch (err) {};
146
- if (!_reporter) try { _reporter = require(reporter); } catch (err) {};
146
+ try { _reporter = require('./reporters/' + reporter); } catch (err) {}
147
+ if (!_reporter) try { _reporter = require(reporter); } catch (err) {
148
+ err.message.indexOf('Cannot find module') !== -1
149
+ ? console.warn('"' + reporter + '" reporter not found')
150
+ : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
151
+ }
147
152
  if (!_reporter && reporter === 'teamcity')
148
153
  console.warn('The Teamcity reporter was moved to a package named ' +
149
154
  'mocha-teamcity-reporter ' +
@@ -165,7 +170,7 @@ Mocha.prototype.reporter = function(reporter, reporterOptions){
165
170
  Mocha.prototype.ui = function(name){
166
171
  name = name || 'bdd';
167
172
  this._ui = exports.interfaces[name];
168
- if (!this._ui) try { this._ui = require(name); } catch (err) {};
173
+ if (!this._ui) try { this._ui = require(name); } catch (err) {}
169
174
  if (!this._ui) throw new Error('invalid interface "' + name + '"');
170
175
  this._ui = this._ui(this.suite);
171
176
  return this;
@@ -266,6 +271,18 @@ Mocha.prototype.checkLeaks = function(){
266
271
  return this;
267
272
  };
268
273
 
274
+ /**
275
+ * Display long stack-trace on failing
276
+ *
277
+ * @return {Mocha}
278
+ * @api public
279
+ */
280
+
281
+ Mocha.prototype.fullTrace = function() {
282
+ this.options.fullStackTrace = true;
283
+ return this;
284
+ };
285
+
269
286
  /**
270
287
  * Enable growl support.
271
288
  *
@@ -409,6 +426,7 @@ Mocha.prototype.run = function(fn){
409
426
  var runner = new exports.Runner(suite, options.delay);
410
427
  var reporter = new this._reporter(runner, options);
411
428
  runner.ignoreLeaks = false !== options.ignoreLeaks;
429
+ runner.fullStackTrace = options.fullStackTrace;
412
430
  runner.asyncOnly = options.asyncOnly;
413
431
  if (options.grep) runner.grep(options.grep, options.invert);
414
432
  if (options.globals) runner.globals(options.globals);
@@ -66,8 +66,8 @@ exports.colors = {
66
66
  , 'green': 32
67
67
  , 'light': 90
68
68
  , 'diff gutter': 90
69
- , 'diff added': 42
70
- , 'diff removed': 41
69
+ , 'diff added': 32
70
+ , 'diff removed': 31
71
71
  };
72
72
 
73
73
  /**
@@ -168,21 +168,29 @@ exports.list = function(failures){
168
168
  var err = test.err
169
169
  , message = err.message || ''
170
170
  , stack = err.stack || message
171
- , index = stack.indexOf(message) + message.length
172
- , msg = stack.slice(0, index)
171
+ , index = stack.indexOf(message)
173
172
  , actual = err.actual
174
173
  , expected = err.expected
175
174
  , escape = true;
175
+ if (index === -1) {
176
+ msg = message;
177
+ } else {
178
+ index += message.length;
179
+ msg = stack.slice(0, index);
180
+ // remove msg from stack
181
+ stack = stack.slice(index + 1);
182
+ }
176
183
 
177
184
  // uncaught
178
185
  if (err.uncaught) {
179
186
  msg = 'Uncaught ' + msg;
180
187
  }
181
188
  // explicitly show diff
182
- if (err.showDiff && sameType(actual, expected)) {
189
+ if (err.showDiff !== false && sameType(actual, expected)
190
+ && expected !== undefined) {
183
191
 
184
- if ('string' !== typeof actual) {
185
- escape = false;
192
+ escape = false;
193
+ if (!(utils.isString(actual) && utils.isString(expected))) {
186
194
  err.actual = actual = utils.stringify(actual);
187
195
  err.expected = expected = utils.stringify(expected);
188
196
  }
@@ -198,9 +206,8 @@ exports.list = function(failures){
198
206
  }
199
207
  }
200
208
 
201
- // indent stack trace without msg
202
- stack = stack.slice(index ? index + 1 : index)
203
- .replace(/^/gm, ' ');
209
+ // indent stack trace
210
+ stack = stack.replace(/^/gm, ' ');
204
211
 
205
212
  console.log(fmt, (i + 1), test.fullTitle(), msg, stack);
206
213
  });
@@ -27,7 +27,7 @@ function Dot(runner) {
27
27
  , n = -1;
28
28
 
29
29
  runner.on('start', function(){
30
- process.stdout.write('\n ');
30
+ process.stdout.write('\n');
31
31
  });
32
32
 
33
33
  runner.on('pending', function(test){
@@ -54,14 +54,14 @@ function Spec(runner) {
54
54
  if ('fast' == test.speed) {
55
55
  var fmt = indent()
56
56
  + color('checkmark', ' ' + Base.symbols.ok)
57
- + color('pass', ' %s ');
57
+ + color('pass', ' %s');
58
58
  cursor.CR();
59
59
  console.log(fmt, test.title);
60
60
  } else {
61
61
  var fmt = indent()
62
62
  + color('checkmark', ' ' + Base.symbols.ok)
63
- + color('pass', ' %s ')
64
- + color(test.speed, '(%dms)');
63
+ + color('pass', ' %s')
64
+ + color(test.speed, ' (%dms)');
65
65
  cursor.CR();
66
66
  console.log(fmt, test.title, test.duration);
67
67
  }
@@ -10,4 +10,4 @@
10
10
  if segments.length
11
11
  span.dirname= segments.join('/') + '/'
12
12
  span.basename= basename
13
- a#logo(href='http://visionmedia.github.io/mocha/') m
13
+ a#logo(href='http://mochajs.org/') m
@@ -8,7 +8,7 @@ body {
8
8
  }
9
9
 
10
10
  #coverage {
11
- padding: 60px;
11
+ padding: 60px 400px 60px 60px;
12
12
  }
13
13
 
14
14
  h1 a {
@@ -124,6 +124,10 @@ footer span {
124
124
  padding: 15px 0;
125
125
  text-align: right;
126
126
  border-left: 1px solid #eee;
127
+ max-width: 400px;
128
+ overflow: auto;
129
+ white-space: nowrap;
130
+
127
131
  -moz-box-shadow: 0 0 2px #888
128
132
  , inset 5px 0 20px rgba(0,0,0,.5)
129
133
  , inset 5px 0 3px rgba(0,0,0,.3);
package/lib/runner.js CHANGED
@@ -10,7 +10,8 @@ var EventEmitter = require('events').EventEmitter
10
10
  , filter = utils.filter
11
11
  , keys = utils.keys
12
12
  , type = utils.type
13
- , stringify = utils.stringify;
13
+ , stringify = utils.stringify
14
+ , stackFilter = utils.stackTraceFilter();
14
15
 
15
16
  /**
16
17
  * Non-enumerable globals.
@@ -197,16 +198,18 @@ Runner.prototype.checkGlobals = function(test){
197
198
  * @api private
198
199
  */
199
200
 
200
- Runner.prototype.fail = function(test, err){
201
+ Runner.prototype.fail = function(test, err) {
201
202
  ++this.failures;
202
203
  test.state = 'failed';
203
204
 
204
- if ('string' == typeof err) {
205
- err = new Error('the string "' + err + '" was thrown, throw an Error :)');
206
- } else if (!(err instanceof Error)) {
205
+ if (!(err instanceof Error)) {
207
206
  err = new Error('the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)');
208
207
  }
209
208
 
209
+ err.stack = (this.fullStackTrace || !err.stack)
210
+ ? err.stack
211
+ : stackFilter(err.stack);
212
+
210
213
  this.emit('fail', test, err);
211
214
  };
212
215
 
@@ -694,20 +697,20 @@ function filterLeaks(ok, globals) {
694
697
  * @api private
695
698
  */
696
699
 
697
- function extraGlobals() {
698
- if (typeof(process) === 'object' &&
699
- typeof(process.version) === 'string') {
700
+ function extraGlobals() {
701
+ if (typeof(process) === 'object' &&
702
+ typeof(process.version) === 'string') {
700
703
 
701
- var nodeVersion = process.version.split('.').reduce(function(a, v) {
702
- return a << 8 | v;
703
- });
704
+ var nodeVersion = process.version.split('.').reduce(function(a, v) {
705
+ return a << 8 | v;
706
+ });
704
707
 
705
- // 'errno' was renamed to process._errno in v0.9.11.
708
+ // 'errno' was renamed to process._errno in v0.9.11.
706
709
 
707
- if (nodeVersion < 0x00090B) {
708
- return ['errno'];
709
- }
710
- }
711
-
712
- return [];
710
+ if (nodeVersion < 0x00090B) {
711
+ return ['errno'];
712
+ }
713
713
  }
714
+
715
+ return [];
716
+ }