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/lib/runnable.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
var EventEmitter = require('events').EventEmitter
|
|
7
|
-
, debug = require('debug')('runnable');
|
|
7
|
+
, debug = require('debug')('mocha:runnable');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Save timer references to avoid Sinon interfering (see GH-237).
|
|
@@ -146,16 +146,16 @@ Runnable.prototype.run = function(fn){
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
// called multiple times
|
|
149
|
-
function multiple() {
|
|
149
|
+
function multiple(err) {
|
|
150
150
|
if (emitted) return;
|
|
151
151
|
emitted = true;
|
|
152
|
-
self.emit('error', new Error('done() called multiple times'));
|
|
152
|
+
self.emit('error', err || new Error('done() called multiple times'));
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
// finished
|
|
156
156
|
function done(err) {
|
|
157
157
|
if (self.timedOut) return;
|
|
158
|
-
if (finished) return multiple();
|
|
158
|
+
if (finished) return multiple(err);
|
|
159
159
|
self.clearTimeout();
|
|
160
160
|
self.duration = new Date - start;
|
|
161
161
|
finished = true;
|
package/lib/runner.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
var EventEmitter = require('events').EventEmitter
|
|
7
|
-
, debug = require('debug')('runner')
|
|
7
|
+
, debug = require('debug')('mocha:runner')
|
|
8
8
|
, Test = require('./test')
|
|
9
9
|
, utils = require('./utils')
|
|
10
10
|
, filter = utils.filter
|
|
@@ -59,13 +59,15 @@ Runner.prototype.__proto__ = EventEmitter.prototype;
|
|
|
59
59
|
* with number of tests matched.
|
|
60
60
|
*
|
|
61
61
|
* @param {RegExp} re
|
|
62
|
+
* @param {Boolean} invert
|
|
62
63
|
* @return {Runner} for chaining
|
|
63
64
|
* @api public
|
|
64
65
|
*/
|
|
65
66
|
|
|
66
|
-
Runner.prototype.grep = function(re){
|
|
67
|
+
Runner.prototype.grep = function(re, invert){
|
|
67
68
|
debug('grep %s', re);
|
|
68
69
|
this._grep = re;
|
|
70
|
+
this._invert = invert;
|
|
69
71
|
this.total = this.grepTotal(this.suite);
|
|
70
72
|
return this;
|
|
71
73
|
};
|
|
@@ -84,7 +86,9 @@ Runner.prototype.grepTotal = function(suite) {
|
|
|
84
86
|
var total = 0;
|
|
85
87
|
|
|
86
88
|
suite.eachTest(function(test){
|
|
87
|
-
|
|
89
|
+
var match = self._grep.test(test.fullTitle());
|
|
90
|
+
if (self._invert) match = !match;
|
|
91
|
+
if (match) total++;
|
|
88
92
|
});
|
|
89
93
|
|
|
90
94
|
return total;
|
|
@@ -324,7 +328,9 @@ Runner.prototype.runTests = function(suite, fn){
|
|
|
324
328
|
if (!test) return fn();
|
|
325
329
|
|
|
326
330
|
// grep
|
|
327
|
-
|
|
331
|
+
var match = self._grep.test(test.fullTitle());
|
|
332
|
+
if (self._invert) match = !match;
|
|
333
|
+
if (!match) return next();
|
|
328
334
|
|
|
329
335
|
// pending
|
|
330
336
|
if (test.pending) {
|
|
@@ -405,9 +411,9 @@ Runner.prototype.runSuite = function(suite, fn){
|
|
|
405
411
|
*/
|
|
406
412
|
|
|
407
413
|
Runner.prototype.uncaught = function(err){
|
|
408
|
-
debug('uncaught exception');
|
|
414
|
+
debug('uncaught exception %s', err.message);
|
|
409
415
|
var runnable = this.currentRunnable;
|
|
410
|
-
if ('failed' == runnable.state) return;
|
|
416
|
+
if (!runnable || 'failed' == runnable.state) return;
|
|
411
417
|
runnable.clearTimeout();
|
|
412
418
|
err.uncaught = true;
|
|
413
419
|
this.fail(runnable, err);
|
package/lib/suite.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
var EventEmitter = require('events').EventEmitter
|
|
7
|
-
, debug = require('debug')('suite')
|
|
7
|
+
, debug = require('debug')('mocha:suite')
|
|
8
8
|
, utils = require('./utils')
|
|
9
9
|
, Hook = require('./hook');
|
|
10
10
|
|
|
@@ -30,6 +30,7 @@ exports = module.exports = Suite;
|
|
|
30
30
|
exports.create = function(parent, title){
|
|
31
31
|
var suite = new Suite(title, parent.ctx);
|
|
32
32
|
suite.parent = parent;
|
|
33
|
+
if (parent.pending) suite.pending = true;
|
|
33
34
|
title = suite.fullTitle();
|
|
34
35
|
parent.addSuite(suite);
|
|
35
36
|
return suite;
|
|
@@ -49,6 +50,7 @@ function Suite(title, ctx) {
|
|
|
49
50
|
this.ctx = ctx;
|
|
50
51
|
this.suites = [];
|
|
51
52
|
this.tests = [];
|
|
53
|
+
this.pending = false;
|
|
52
54
|
this._beforeEach = [];
|
|
53
55
|
this._beforeAll = [];
|
|
54
56
|
this._afterEach = [];
|
|
@@ -120,6 +122,7 @@ Suite.prototype.bail = function(bail){
|
|
|
120
122
|
*/
|
|
121
123
|
|
|
122
124
|
Suite.prototype.beforeAll = function(fn){
|
|
125
|
+
if (this.pending) return this;
|
|
123
126
|
var hook = new Hook('"before all" hook', fn);
|
|
124
127
|
hook.parent = this;
|
|
125
128
|
hook.timeout(this.timeout());
|
|
@@ -138,6 +141,7 @@ Suite.prototype.beforeAll = function(fn){
|
|
|
138
141
|
*/
|
|
139
142
|
|
|
140
143
|
Suite.prototype.afterAll = function(fn){
|
|
144
|
+
if (this.pending) return this;
|
|
141
145
|
var hook = new Hook('"after all" hook', fn);
|
|
142
146
|
hook.parent = this;
|
|
143
147
|
hook.timeout(this.timeout());
|
|
@@ -156,6 +160,7 @@ Suite.prototype.afterAll = function(fn){
|
|
|
156
160
|
*/
|
|
157
161
|
|
|
158
162
|
Suite.prototype.beforeEach = function(fn){
|
|
163
|
+
if (this.pending) return this;
|
|
159
164
|
var hook = new Hook('"before each" hook', fn);
|
|
160
165
|
hook.parent = this;
|
|
161
166
|
hook.timeout(this.timeout());
|
|
@@ -174,6 +179,7 @@ Suite.prototype.beforeEach = function(fn){
|
|
|
174
179
|
*/
|
|
175
180
|
|
|
176
181
|
Suite.prototype.afterEach = function(fn){
|
|
182
|
+
if (this.pending) return this;
|
|
177
183
|
var hook = new Hook('"after each" hook', fn);
|
|
178
184
|
hook.parent = this;
|
|
179
185
|
hook.timeout(this.timeout());
|
package/lib/utils.js
CHANGED
package/mocha.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
@charset "UTF-8";
|
|
2
2
|
body {
|
|
3
3
|
font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
4
4
|
padding: 60px 50px;
|
|
@@ -143,6 +143,14 @@ body {
|
|
|
143
143
|
-webkit-box-shadow: 0 1px 3px #eee;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
#report.pass .test.fail {
|
|
147
|
+
display: none;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
#report.fail .test.pass {
|
|
151
|
+
display: none;
|
|
152
|
+
}
|
|
153
|
+
|
|
146
154
|
#error {
|
|
147
155
|
color: #c00;
|
|
148
156
|
font-size: 1.5 em;
|
|
@@ -168,6 +176,15 @@ body {
|
|
|
168
176
|
color: black;
|
|
169
177
|
}
|
|
170
178
|
|
|
179
|
+
#stats a {
|
|
180
|
+
text-decoration: none;
|
|
181
|
+
color: inherit;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#stats a:hover {
|
|
185
|
+
border-bottom: 1px solid #eee;
|
|
186
|
+
}
|
|
187
|
+
|
|
171
188
|
#stats li {
|
|
172
189
|
display: inline-block;
|
|
173
190
|
margin: 0 5px;
|