mocha 1.2.1 → 1.3.2
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/.npmignore +2 -0
- package/.travis.yml +1 -1
- package/History.md +38 -0
- package/Makefile +9 -2
- package/_mocha.js +160 -63
- package/bin/_mocha +66 -61
- package/bin/mocha +5 -1
- package/lib/interfaces/bdd.js +23 -6
- package/lib/mocha.js +55 -10
- package/lib/reporters/base.js +5 -5
- package/lib/reporters/dot.js +5 -4
- package/lib/reporters/html.js +28 -13
- package/lib/reporters/index.js +3 -2
- package/lib/reporters/landing.js +2 -2
- package/lib/reporters/min.js +3 -2
- package/lib/reporters/nyan.js +6 -6
- package/lib/reporters/progress.js +1 -1
- package/lib/reporters/xunit.js +5 -1
- package/lib/runnable.js +4 -4
- package/lib/runner.js +12 -6
- package/lib/suite.js +7 -1
- package/lib/utils.js +1 -1
- package/mocha.css +18 -1
- package/mocha.js +160 -63
- package/my-reporter.js +23 -0
- package/package.json +2 -2
- package/test.js +5 -11
- package/editors/JavaScript mocha.tmbundle/Snippets/bdd - after each.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/Snippets/bdd - after.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/Snippets/bdd - before each.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/Snippets/bdd - before.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/Snippets/bdd - it.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/Snippets/untitled.tmSnippet +0 -16
- package/editors/JavaScript mocha.tmbundle/info.plist +0 -19
- package/support/compile.js +0 -154
- package/support/foot.js +0 -1
- package/support/head.js +0 -2
- package/support/tail.js +0 -150
- package/support/template.html +0 -16
package/bin/_mocha
CHANGED
|
@@ -11,15 +11,15 @@ var program = require('commander')
|
|
|
11
11
|
, vm = require('vm')
|
|
12
12
|
, resolve = path.resolve
|
|
13
13
|
, exists = fs.existsSync || path.existsSync
|
|
14
|
-
,
|
|
15
|
-
, utils =
|
|
16
|
-
, reporters =
|
|
17
|
-
, interfaces =
|
|
18
|
-
,
|
|
19
|
-
, Runner = mocha.Runner
|
|
20
|
-
, Suite = mocha.Suite
|
|
14
|
+
, Mocha = require('../')
|
|
15
|
+
, utils = Mocha.utils
|
|
16
|
+
, reporters = Mocha.reporters
|
|
17
|
+
, interfaces = Mocha.interfaces
|
|
18
|
+
, Base = reporters.Base
|
|
21
19
|
, join = path.join
|
|
22
|
-
,
|
|
20
|
+
, basename = path.basename
|
|
21
|
+
, cwd = process.cwd()
|
|
22
|
+
, mocha = new Mocha;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Save timer references to avoid Sinon interfering (see GH-237).
|
|
@@ -55,12 +55,13 @@ var images = {
|
|
|
55
55
|
// options
|
|
56
56
|
|
|
57
57
|
program
|
|
58
|
-
.version(
|
|
58
|
+
.version(JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version)
|
|
59
59
|
.usage('[debug] [options] [files]')
|
|
60
60
|
.option('-r, --require <name>', 'require the given module')
|
|
61
61
|
.option('-R, --reporter <name>', 'specify the reporter to use', 'dot')
|
|
62
62
|
.option('-u, --ui <name>', 'specify user-interface (bdd|tdd|exports)', 'bdd')
|
|
63
63
|
.option('-g, --grep <pattern>', 'only run tests matching <pattern>')
|
|
64
|
+
.option('-i, --invert', 'inverts --grep matches')
|
|
64
65
|
.option('-t, --timeout <ms>', 'set test-case timeout in milliseconds [2000]')
|
|
65
66
|
.option('-s, --slow <ms>', '"slow" test threshold in milliseconds [75]', parseInt)
|
|
66
67
|
.option('-w, --watch', 'watch files for changes')
|
|
@@ -172,10 +173,23 @@ Error.stackTraceLimit = Infinity; // TODO: config
|
|
|
172
173
|
|
|
173
174
|
// reporter
|
|
174
175
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
mocha.reporter(program.reporter);
|
|
177
|
+
|
|
178
|
+
// interface
|
|
179
|
+
|
|
180
|
+
mocha.ui(program.ui);
|
|
181
|
+
|
|
182
|
+
// load reporter
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
Reporter = require('../lib/reporters/' + program.reporter);
|
|
186
|
+
} catch (err) {
|
|
187
|
+
try {
|
|
188
|
+
Reporter = require(program.reporter);
|
|
189
|
+
} catch (err) {
|
|
190
|
+
throw new Error('reporter "' + program.reporter + '" does not exist');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
179
193
|
|
|
180
194
|
// --no-colors
|
|
181
195
|
|
|
@@ -194,11 +208,31 @@ if (program.slow) Base.slow = program.slow;
|
|
|
194
208
|
|
|
195
209
|
// --timeout
|
|
196
210
|
|
|
197
|
-
if (program.timeout) suite.timeout(program.timeout);
|
|
211
|
+
if (program.timeout) mocha.suite.timeout(program.timeout);
|
|
198
212
|
|
|
199
213
|
// --bail
|
|
200
214
|
|
|
201
|
-
suite.bail(program.bail);
|
|
215
|
+
mocha.suite.bail(program.bail);
|
|
216
|
+
|
|
217
|
+
// --grep
|
|
218
|
+
|
|
219
|
+
if (program.grep) mocha.grep(new RegExp(utils.escapeRegexp(program.grep)));
|
|
220
|
+
|
|
221
|
+
// --invert
|
|
222
|
+
|
|
223
|
+
if (program.invert) mocha.invert();
|
|
224
|
+
|
|
225
|
+
// --ignore-leaks
|
|
226
|
+
|
|
227
|
+
if (program.ignoreLeaks) mocha.ignoreLeaks();
|
|
228
|
+
|
|
229
|
+
// --growl
|
|
230
|
+
|
|
231
|
+
if (program.growl) mocha.growl();
|
|
232
|
+
|
|
233
|
+
// --globals
|
|
234
|
+
|
|
235
|
+
mocha.globals(globals);
|
|
202
236
|
|
|
203
237
|
// custom compiler support
|
|
204
238
|
|
|
@@ -246,21 +280,20 @@ if (program.watch) {
|
|
|
246
280
|
});
|
|
247
281
|
|
|
248
282
|
var frames = [
|
|
249
|
-
' \
|
|
250
|
-
, ' \
|
|
251
|
-
, ' \
|
|
252
|
-
, ' \
|
|
253
|
-
, ' \
|
|
254
|
-
, ' \
|
|
283
|
+
' \u001b[96m◜ \u001b[90mwatching\u001b[0m'
|
|
284
|
+
, ' \u001b[96m◠ \u001b[90mwatching\u001b[0m'
|
|
285
|
+
, ' \u001b[96m◝ \u001b[90mwatching\u001b[0m'
|
|
286
|
+
, ' \u001b[96m◞ \u001b[90mwatching\u001b[0m'
|
|
287
|
+
, ' \u001b[96m◡ \u001b[90mwatching\u001b[0m'
|
|
288
|
+
, ' \u001b[96m◟ \u001b[90mwatching\u001b[0m'
|
|
255
289
|
];
|
|
256
290
|
|
|
257
291
|
var watchFiles = utils.files(cwd);
|
|
258
292
|
|
|
259
293
|
function loadAndRun() {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
});
|
|
294
|
+
mocha.files = files;
|
|
295
|
+
mocha.run(function(){
|
|
296
|
+
play(frames);
|
|
264
297
|
});
|
|
265
298
|
}
|
|
266
299
|
|
|
@@ -275,8 +308,8 @@ if (program.watch) {
|
|
|
275
308
|
utils.watch(watchFiles, function(){
|
|
276
309
|
purge();
|
|
277
310
|
stop()
|
|
278
|
-
suite = suite.clone();
|
|
279
|
-
ui
|
|
311
|
+
mocha.suite = mocha.suite.clone();
|
|
312
|
+
mocha.ui(program.ui);
|
|
280
313
|
loadAndRun();
|
|
281
314
|
});
|
|
282
315
|
|
|
@@ -285,36 +318,8 @@ if (program.watch) {
|
|
|
285
318
|
|
|
286
319
|
// load
|
|
287
320
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
// require test files before
|
|
293
|
-
// running the root suite
|
|
294
|
-
|
|
295
|
-
function load(files, fn) {
|
|
296
|
-
var pending = files.length;
|
|
297
|
-
files.forEach(function(file){
|
|
298
|
-
delete require.cache[file];
|
|
299
|
-
suite.emit('pre-require', global, file);
|
|
300
|
-
suite.emit('require', require(file), file);
|
|
301
|
-
suite.emit('post-require', global, file);
|
|
302
|
-
--pending || fn();
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// run the given suite
|
|
307
|
-
|
|
308
|
-
function run(suite, fn) {
|
|
309
|
-
suite.emit('run');
|
|
310
|
-
var runner = new Runner(suite);
|
|
311
|
-
runner.globals(globals);
|
|
312
|
-
if (program.ignoreLeaks) runner.ignoreLeaks = true;
|
|
313
|
-
if (program.grep) runner.grep(new RegExp(program.grep));
|
|
314
|
-
var reporter = new Reporter(runner);
|
|
315
|
-
if (program.growl) growl(runner, reporter);
|
|
316
|
-
runner.run(fn);
|
|
317
|
-
}
|
|
321
|
+
mocha.files = files;
|
|
322
|
+
mocha.run(process.exit);
|
|
318
323
|
|
|
319
324
|
// enable growl notifications
|
|
320
325
|
|
|
@@ -349,7 +354,7 @@ function list(str) {
|
|
|
349
354
|
*/
|
|
350
355
|
|
|
351
356
|
function hideCursor(){
|
|
352
|
-
process.stdout.write('\
|
|
357
|
+
process.stdout.write('\u001b[?25l');
|
|
353
358
|
};
|
|
354
359
|
|
|
355
360
|
/**
|
|
@@ -357,7 +362,7 @@ function hideCursor(){
|
|
|
357
362
|
*/
|
|
358
363
|
|
|
359
364
|
function showCursor(){
|
|
360
|
-
process.stdout.write('\
|
|
365
|
+
process.stdout.write('\u001b[?25h');
|
|
361
366
|
};
|
|
362
367
|
|
|
363
368
|
/**
|
|
@@ -365,7 +370,7 @@ function showCursor(){
|
|
|
365
370
|
*/
|
|
366
371
|
|
|
367
372
|
function stop() {
|
|
368
|
-
process.stdout.write('\
|
|
373
|
+
process.stdout.write('\u001b[2K');
|
|
369
374
|
clearInterval(play.timer);
|
|
370
375
|
}
|
|
371
376
|
|
|
@@ -387,7 +392,7 @@ function lookupFiles(path, recursive) {
|
|
|
387
392
|
if (recursive) files = files.concat(lookupFiles(file, recursive));
|
|
388
393
|
return
|
|
389
394
|
}
|
|
390
|
-
if (!stat.isFile() || !re.test(file)) return;
|
|
395
|
+
if (!stat.isFile() || !re.test(file) || basename(file)[0] == '.') return;
|
|
391
396
|
files.push(file);
|
|
392
397
|
});
|
|
393
398
|
|
package/bin/mocha
CHANGED
|
@@ -22,8 +22,12 @@ process.argv.slice(2).forEach(function (arg) {
|
|
|
22
22
|
case '--expose-gc':
|
|
23
23
|
args.unshift('--expose-gc');
|
|
24
24
|
break;
|
|
25
|
+
case '--harmony-proxies':
|
|
26
|
+
args.unshift('--harmony-proxies');
|
|
27
|
+
break;
|
|
25
28
|
default:
|
|
26
|
-
args.
|
|
29
|
+
if (0 == arg.indexOf('--trace')) args.unshift(arg);
|
|
30
|
+
else args.push(arg);
|
|
27
31
|
break;
|
|
28
32
|
}
|
|
29
33
|
});
|
package/lib/interfaces/bdd.js
CHANGED
|
@@ -28,11 +28,6 @@ module.exports = function(suite){
|
|
|
28
28
|
|
|
29
29
|
suite.on('pre-require', function(context){
|
|
30
30
|
|
|
31
|
-
// noop variants
|
|
32
|
-
|
|
33
|
-
context.xdescribe = function(){};
|
|
34
|
-
context.xit = function(){};
|
|
35
|
-
|
|
36
31
|
/**
|
|
37
32
|
* Execute before running tests.
|
|
38
33
|
*/
|
|
@@ -65,6 +60,18 @@ module.exports = function(suite){
|
|
|
65
60
|
suites[0].afterEach(fn);
|
|
66
61
|
};
|
|
67
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Pending describe.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
context.xdescribe = context.xcontext = function(title, fn){
|
|
68
|
+
var suite = Suite.create(suites[0], title);
|
|
69
|
+
suite.pending = true;
|
|
70
|
+
suites.unshift(suite);
|
|
71
|
+
fn();
|
|
72
|
+
suites.shift();
|
|
73
|
+
};
|
|
74
|
+
|
|
68
75
|
/**
|
|
69
76
|
* Describe a "suite" with the given `title`
|
|
70
77
|
* and callback `fn` containing nested suites
|
|
@@ -85,7 +92,17 @@ module.exports = function(suite){
|
|
|
85
92
|
*/
|
|
86
93
|
|
|
87
94
|
context.it = context.specify = function(title, fn){
|
|
88
|
-
suites[0]
|
|
95
|
+
var suite = suites[0];
|
|
96
|
+
if (suite.pending) var fn = null;
|
|
97
|
+
suite.addTest(new Test(title, fn));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Pending test case.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
context.xit = context.xspecify = function(title){
|
|
105
|
+
context.it(title);
|
|
89
106
|
};
|
|
90
107
|
});
|
|
91
108
|
};
|
package/lib/mocha.js
CHANGED
|
@@ -16,12 +16,6 @@ var path = require('path');
|
|
|
16
16
|
|
|
17
17
|
exports = module.exports = Mocha;
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Library version.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
exports.version = '1.2.1';
|
|
24
|
-
|
|
25
19
|
/**
|
|
26
20
|
* Expose internals.
|
|
27
21
|
*/
|
|
@@ -122,13 +116,15 @@ Mocha.prototype.ui = function(name){
|
|
|
122
116
|
* @api private
|
|
123
117
|
*/
|
|
124
118
|
|
|
125
|
-
Mocha.prototype.loadFiles = function(){
|
|
119
|
+
Mocha.prototype.loadFiles = function(fn){
|
|
126
120
|
var suite = this.suite;
|
|
121
|
+
var pending = this.files.length;
|
|
127
122
|
this.files.forEach(function(file){
|
|
128
123
|
file = path.resolve(file);
|
|
129
124
|
suite.emit('pre-require', global, file);
|
|
130
125
|
suite.emit('require', require(file), file);
|
|
131
126
|
suite.emit('post-require', global, file);
|
|
127
|
+
--pending || (fn && fn());
|
|
132
128
|
});
|
|
133
129
|
};
|
|
134
130
|
|
|
@@ -138,7 +134,7 @@ Mocha.prototype.loadFiles = function(){
|
|
|
138
134
|
* @api private
|
|
139
135
|
*/
|
|
140
136
|
|
|
141
|
-
Mocha.prototype.
|
|
137
|
+
Mocha.prototype._growl = function(runner, reporter) {
|
|
142
138
|
var notify = require('growl');
|
|
143
139
|
|
|
144
140
|
runner.on('end', function(){
|
|
@@ -171,6 +167,55 @@ Mocha.prototype.grep = function(re){
|
|
|
171
167
|
return this;
|
|
172
168
|
};
|
|
173
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Invert `.grep()` matches.
|
|
172
|
+
*
|
|
173
|
+
* @return {Mocha}
|
|
174
|
+
* @api public
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
Mocha.prototype.invert = function(){
|
|
178
|
+
this.options.invert = true;
|
|
179
|
+
return this;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Ignore global leaks.
|
|
184
|
+
*
|
|
185
|
+
* @return {Mocha}
|
|
186
|
+
* @api public
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
Mocha.prototype.ignoreLeaks = function(){
|
|
190
|
+
this.options.ignoreLeaks = true;
|
|
191
|
+
return this;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Enable growl support.
|
|
196
|
+
*
|
|
197
|
+
* @return {Mocha}
|
|
198
|
+
* @api public
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
Mocha.prototype.growl = function(){
|
|
202
|
+
this.options.growl = true;
|
|
203
|
+
return this;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Ignore `globals`.
|
|
208
|
+
*
|
|
209
|
+
* @param {Array} globals
|
|
210
|
+
* @return {Mocha}
|
|
211
|
+
* @api public
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
Mocha.prototype.globals = function(globals){
|
|
215
|
+
this.options.globals = globals;
|
|
216
|
+
return this;
|
|
217
|
+
};
|
|
218
|
+
|
|
174
219
|
/**
|
|
175
220
|
* Run tests and invoke `fn()` when complete.
|
|
176
221
|
*
|
|
@@ -186,8 +231,8 @@ Mocha.prototype.run = function(fn){
|
|
|
186
231
|
var runner = new exports.Runner(suite);
|
|
187
232
|
var reporter = new this._reporter(runner);
|
|
188
233
|
runner.ignoreLeaks = options.ignoreLeaks;
|
|
189
|
-
if (options.grep) runner.grep(options.grep);
|
|
234
|
+
if (options.grep) runner.grep(options.grep, options.invert);
|
|
190
235
|
if (options.globals) runner.globals(options.globals);
|
|
191
|
-
if (options.growl) this.
|
|
236
|
+
if (options.growl) this._growl(runner, reporter);
|
|
192
237
|
return runner.run(fn);
|
|
193
238
|
};
|
package/lib/reporters/base.js
CHANGED
|
@@ -74,7 +74,7 @@ exports.colors = {
|
|
|
74
74
|
|
|
75
75
|
var color = exports.color = function(type, str) {
|
|
76
76
|
if (!exports.useColors) return str;
|
|
77
|
-
return '\
|
|
77
|
+
return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -97,19 +97,19 @@ exports.window = {
|
|
|
97
97
|
|
|
98
98
|
exports.cursor = {
|
|
99
99
|
hide: function(){
|
|
100
|
-
process.stdout.write('\
|
|
100
|
+
process.stdout.write('\u001b[?25l');
|
|
101
101
|
},
|
|
102
102
|
|
|
103
103
|
show: function(){
|
|
104
|
-
process.stdout.write('\
|
|
104
|
+
process.stdout.write('\u001b[?25h');
|
|
105
105
|
},
|
|
106
106
|
|
|
107
107
|
deleteLine: function(){
|
|
108
|
-
process.stdout.write('\
|
|
108
|
+
process.stdout.write('\u001b[2K');
|
|
109
109
|
},
|
|
110
110
|
|
|
111
111
|
beginningOfLine: function(){
|
|
112
|
-
process.stdout.write('\
|
|
112
|
+
process.stdout.write('\u001b[0G');
|
|
113
113
|
},
|
|
114
114
|
|
|
115
115
|
CR: function(){
|
package/lib/reporters/dot.js
CHANGED
|
@@ -25,6 +25,7 @@ function Dot(runner) {
|
|
|
25
25
|
var self = this
|
|
26
26
|
, stats = this.stats
|
|
27
27
|
, width = Base.window.width * .75 | 0
|
|
28
|
+
, c = '․'
|
|
28
29
|
, n = 0;
|
|
29
30
|
|
|
30
31
|
runner.on('start', function(){
|
|
@@ -32,21 +33,21 @@ function Dot(runner) {
|
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
runner.on('pending', function(test){
|
|
35
|
-
process.stdout.write(color('pending',
|
|
36
|
+
process.stdout.write(color('pending', c));
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
runner.on('pass', function(test){
|
|
39
40
|
if (++n % width == 0) process.stdout.write('\n ');
|
|
40
41
|
if ('slow' == test.speed) {
|
|
41
|
-
process.stdout.write(color('bright yellow',
|
|
42
|
+
process.stdout.write(color('bright yellow', c));
|
|
42
43
|
} else {
|
|
43
|
-
process.stdout.write(color(test.speed,
|
|
44
|
+
process.stdout.write(color(test.speed, c));
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
runner.on('fail', function(test, err){
|
|
48
49
|
if (++n % width == 0) process.stdout.write('\n ');
|
|
49
|
-
process.stdout.write(color('fail',
|
|
50
|
+
process.stdout.write(color('fail', c));
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
runner.on('end', function(){
|
package/lib/reporters/html.js
CHANGED
|
@@ -30,8 +30,8 @@ exports = module.exports = HTML;
|
|
|
30
30
|
|
|
31
31
|
var statsTemplate = '<ul id="stats">'
|
|
32
32
|
+ '<li class="progress"><canvas width="40" height="40"></canvas></li>'
|
|
33
|
-
+ '<li class="passes">passes
|
|
34
|
-
+ '<li class="failures">failures
|
|
33
|
+
+ '<li class="passes"><a href="#">passes:</a> <em>0</em></li>'
|
|
34
|
+
+ '<li class="failures"><a href="#">failures:</a> <em>0</em></li>'
|
|
35
35
|
+ '<li class="duration">duration: <em>0</em>s</li>'
|
|
36
36
|
+ '</ul>';
|
|
37
37
|
|
|
@@ -52,7 +52,9 @@ function HTML(runner) {
|
|
|
52
52
|
, stat = fragment(statsTemplate)
|
|
53
53
|
, items = stat.getElementsByTagName('li')
|
|
54
54
|
, passes = items[1].getElementsByTagName('em')[0]
|
|
55
|
+
, passesLink = items[1].getElementsByTagName('a')[0]
|
|
55
56
|
, failures = items[2].getElementsByTagName('em')[0]
|
|
57
|
+
, failuresLink = items[2].getElementsByTagName('a')[0]
|
|
56
58
|
, duration = items[3].getElementsByTagName('em')[0]
|
|
57
59
|
, canvas = stat.getElementsByTagName('canvas')[0]
|
|
58
60
|
, report = fragment('<ul id="report"></ul>')
|
|
@@ -67,6 +69,18 @@ function HTML(runner) {
|
|
|
67
69
|
|
|
68
70
|
if (!root) return error('#mocha div missing, add it to your document');
|
|
69
71
|
|
|
72
|
+
// pass toggle
|
|
73
|
+
on(passesLink, 'click', function () {
|
|
74
|
+
var className = /pass/.test(report.className) ? '' : ' pass';
|
|
75
|
+
report.className = report.className.replace(/fail|pass/g, '') + className;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// failure toggle
|
|
79
|
+
on(failuresLink, 'click', function () {
|
|
80
|
+
var className = /fail/.test(report.className) ? '' : ' fail';
|
|
81
|
+
report.className = report.className.replace(/fail|pass/g, '') + className;
|
|
82
|
+
});
|
|
83
|
+
|
|
70
84
|
root.appendChild(stat);
|
|
71
85
|
root.appendChild(report);
|
|
72
86
|
|
|
@@ -77,7 +91,7 @@ function HTML(runner) {
|
|
|
77
91
|
|
|
78
92
|
// suite
|
|
79
93
|
var url = location.protocol + '//' + location.host + location.pathname + '?grep=^' + utils.escapeRegexp(suite.fullTitle());
|
|
80
|
-
var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, suite.title);
|
|
94
|
+
var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, escape(suite.title));
|
|
81
95
|
|
|
82
96
|
// container
|
|
83
97
|
stack[0].appendChild(el);
|
|
@@ -95,6 +109,8 @@ function HTML(runner) {
|
|
|
95
109
|
});
|
|
96
110
|
|
|
97
111
|
runner.on('test end', function(test){
|
|
112
|
+
window.scrollTo(0, document.body.scrollHeight);
|
|
113
|
+
|
|
98
114
|
// TODO: add to stats
|
|
99
115
|
var percent = stats.tests / total * 100 | 0;
|
|
100
116
|
if (progress) progress.update(percent).draw(ctx);
|
|
@@ -132,17 +148,16 @@ function HTML(runner) {
|
|
|
132
148
|
}
|
|
133
149
|
|
|
134
150
|
// toggle code
|
|
135
|
-
var h2 = el.getElementsByTagName('h2')[0];
|
|
136
|
-
|
|
137
|
-
on(h2, 'click', function(){
|
|
138
|
-
pre.style.display = 'none' == pre.style.display
|
|
139
|
-
? 'block'
|
|
140
|
-
: 'none';
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
// code
|
|
144
151
|
// TODO: defer
|
|
145
152
|
if (!test.pending) {
|
|
153
|
+
var h2 = el.getElementsByTagName('h2')[0];
|
|
154
|
+
|
|
155
|
+
on(h2, 'click', function(){
|
|
156
|
+
pre.style.display = 'none' == pre.style.display
|
|
157
|
+
? 'inline-block'
|
|
158
|
+
: 'none';
|
|
159
|
+
});
|
|
160
|
+
|
|
146
161
|
var pre = fragment('<pre><code>%e</code></pre>', utils.clean(test.fn.toString()));
|
|
147
162
|
el.appendChild(pre);
|
|
148
163
|
pre.style.display = 'none';
|
|
@@ -201,4 +216,4 @@ function on(el, event, fn) {
|
|
|
201
216
|
} else {
|
|
202
217
|
el.attachEvent('on' + event, fn);
|
|
203
218
|
}
|
|
204
|
-
}
|
|
219
|
+
}
|
package/lib/reporters/index.js
CHANGED
|
@@ -8,10 +8,11 @@ exports.HTML = require('./html');
|
|
|
8
8
|
exports.List = require('./list');
|
|
9
9
|
exports.Min = require('./min');
|
|
10
10
|
exports.Spec = require('./spec');
|
|
11
|
+
exports.Nyan = require('./nyan');
|
|
12
|
+
exports.XUnit = require('./xunit');
|
|
11
13
|
exports.Progress = require('./progress');
|
|
12
14
|
exports.Landing = require('./landing');
|
|
13
15
|
exports.JSONCov = require('./json-cov');
|
|
14
16
|
exports.HTMLCov = require('./html-cov');
|
|
15
17
|
exports.JSONStream = require('./json-stream');
|
|
16
|
-
exports.
|
|
17
|
-
exports.Teamcity = require('./teamcity')
|
|
18
|
+
exports.Teamcity = require('./teamcity');
|
package/lib/reporters/landing.js
CHANGED
|
@@ -73,14 +73,14 @@ function Landing(runner) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// render landing strip
|
|
76
|
-
stream.write('\
|
|
76
|
+
stream.write('\u001b[4F\n\n');
|
|
77
77
|
stream.write(runway());
|
|
78
78
|
stream.write('\n ');
|
|
79
79
|
stream.write(color('runway', Array(col).join('⋅')));
|
|
80
80
|
stream.write(plane)
|
|
81
81
|
stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
|
|
82
82
|
stream.write(runway());
|
|
83
|
-
stream.write('\
|
|
83
|
+
stream.write('\u001b[0m');
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
runner.on('end', function(){
|
package/lib/reporters/min.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
/**
|
|
2
3
|
* Module dependencies.
|
|
3
4
|
*/
|
|
@@ -22,9 +23,9 @@ function Min(runner) {
|
|
|
22
23
|
|
|
23
24
|
runner.on('start', function(){
|
|
24
25
|
// clear screen
|
|
25
|
-
process.stdout.write('\
|
|
26
|
+
process.stdout.write('\u001b[2J');
|
|
26
27
|
// set cursor position
|
|
27
|
-
process.stdout.write('\
|
|
28
|
+
process.stdout.write('\u001b[1;3H');
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
runner.on('end', this.epilogue.bind(this));
|
package/lib/reporters/nyan.js
CHANGED
|
@@ -87,7 +87,7 @@ NyanCat.prototype.drawScoreboard = function(){
|
|
|
87
87
|
|
|
88
88
|
function draw(color, n) {
|
|
89
89
|
write(' ');
|
|
90
|
-
write('\
|
|
90
|
+
write('\u001b[' + color + 'm' + n + '\u001b[0m');
|
|
91
91
|
write('\n');
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -126,7 +126,7 @@ NyanCat.prototype.drawRainbow = function(){
|
|
|
126
126
|
var self = this;
|
|
127
127
|
|
|
128
128
|
this.trajectories.forEach(function(line, index) {
|
|
129
|
-
write('\
|
|
129
|
+
write('\u001b[' + self.scoreboardWidth + 'C');
|
|
130
130
|
write(line.join(''));
|
|
131
131
|
write('\n');
|
|
132
132
|
});
|
|
@@ -146,7 +146,7 @@ NyanCat.prototype.drawNyanCat = function(status) {
|
|
|
146
146
|
var startWidth = this.scoreboardWidth + this.trajectories[0].length;
|
|
147
147
|
|
|
148
148
|
[0, 1, 2, 3].forEach(function(index) {
|
|
149
|
-
write('\
|
|
149
|
+
write('\u001b[' + startWidth + 'C');
|
|
150
150
|
|
|
151
151
|
switch (index) {
|
|
152
152
|
case 0:
|
|
@@ -194,7 +194,7 @@ NyanCat.prototype.drawNyanCat = function(status) {
|
|
|
194
194
|
*/
|
|
195
195
|
|
|
196
196
|
NyanCat.prototype.cursorUp = function(n) {
|
|
197
|
-
write('\
|
|
197
|
+
write('\u001b[' + n + 'A');
|
|
198
198
|
};
|
|
199
199
|
|
|
200
200
|
/**
|
|
@@ -205,7 +205,7 @@ NyanCat.prototype.cursorUp = function(n) {
|
|
|
205
205
|
*/
|
|
206
206
|
|
|
207
207
|
NyanCat.prototype.cursorDown = function(n) {
|
|
208
|
-
write('\
|
|
208
|
+
write('\u001b[' + n + 'B');
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
/**
|
|
@@ -241,7 +241,7 @@ NyanCat.prototype.generateColors = function(){
|
|
|
241
241
|
NyanCat.prototype.rainbowify = function(str){
|
|
242
242
|
var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
|
|
243
243
|
this.colorIndex += 1;
|
|
244
|
-
return '\
|
|
244
|
+
return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
|
|
245
245
|
};
|
|
246
246
|
|
|
247
247
|
/**
|
|
@@ -60,7 +60,7 @@ function Progress(runner, options) {
|
|
|
60
60
|
, i = width - n;
|
|
61
61
|
|
|
62
62
|
cursor.CR();
|
|
63
|
-
process.stdout.write('\
|
|
63
|
+
process.stdout.write('\u001b[J');
|
|
64
64
|
process.stdout.write(color('progress', ' ' + options.open));
|
|
65
65
|
process.stdout.write(Array(n).join(options.complete));
|
|
66
66
|
process.stdout.write(Array(i).join(options.incomplete));
|
package/lib/reporters/xunit.js
CHANGED