mocha 7.0.0 → 7.0.1
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 +18 -1344
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/mocha.js +4 -1
- package/lib/runnable.js +10 -1
- package/lib/runner.js +25 -50
- package/mocha.js +40 -53
- package/package.json +4 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(The MIT License)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2011-
|
|
3
|
+
Copyright (c) 2011-2020 OpenJS Foundation and contributors, https://openjsf.org
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -100,6 +100,6 @@ Finally, come [chat with the maintainers](https://gitter.im/mochajs/contributors
|
|
|
100
100
|
|
|
101
101
|
## License
|
|
102
102
|
|
|
103
|
-
[MIT](LICENSE)
|
|
103
|
+
Copyright 2011-2020 OpenJS Foundation and contributors. Licensed [MIT](https://github.com/mochajs/mocha/blob/master/LICENSE).
|
|
104
104
|
|
|
105
105
|
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha?ref=badge_large)
|
package/lib/mocha.js
CHANGED
|
@@ -100,7 +100,10 @@ function Mocha(options) {
|
|
|
100
100
|
this.grep(options.grep)
|
|
101
101
|
.fgrep(options.fgrep)
|
|
102
102
|
.ui(options.ui)
|
|
103
|
-
.reporter(
|
|
103
|
+
.reporter(
|
|
104
|
+
options.reporter,
|
|
105
|
+
options.reporterOption || options.reporterOptions // reporterOptions was previously the only way to specify options to reporter
|
|
106
|
+
)
|
|
104
107
|
.slow(options.slow)
|
|
105
108
|
.global(options.global);
|
|
106
109
|
|
package/lib/runnable.js
CHANGED
|
@@ -335,9 +335,18 @@ Runnable.prototype.run = function(fn) {
|
|
|
335
335
|
fn(err);
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
// for .resetTimeout()
|
|
338
|
+
// for .resetTimeout() and Runner#uncaught()
|
|
339
339
|
this.callback = done;
|
|
340
340
|
|
|
341
|
+
if (this.fn && typeof this.fn.call !== 'function') {
|
|
342
|
+
done(
|
|
343
|
+
new TypeError(
|
|
344
|
+
'A runnable must be passed a function as its second argument.'
|
|
345
|
+
)
|
|
346
|
+
);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
|
|
341
350
|
// explicit async with `done` argument
|
|
342
351
|
if (this.async) {
|
|
343
352
|
this.resetTimeout();
|
package/lib/runner.js
CHANGED
|
@@ -654,7 +654,7 @@ Runner.prototype.runTests = function(suite, fn) {
|
|
|
654
654
|
self.emit(constants.EVENT_TEST_END, test);
|
|
655
655
|
// skip inner afterEach hooks below errSuite level
|
|
656
656
|
var origSuite = self.suite;
|
|
657
|
-
self.suite = errSuite;
|
|
657
|
+
self.suite = errSuite || self.suite;
|
|
658
658
|
return self.hookUp(HOOK_TYPE_AFTER_EACH, function(e, eSuite) {
|
|
659
659
|
self.suite = origSuite;
|
|
660
660
|
next(e, eSuite);
|
|
@@ -724,7 +724,6 @@ Runner.prototype.runSuite = function(suite, fn) {
|
|
|
724
724
|
var i = 0;
|
|
725
725
|
var self = this;
|
|
726
726
|
var total = this.grepTotal(suite);
|
|
727
|
-
var afterAllHookCalled = false;
|
|
728
727
|
|
|
729
728
|
debug('run suite %s', suite.fullTitle());
|
|
730
729
|
|
|
@@ -772,21 +771,13 @@ Runner.prototype.runSuite = function(suite, fn) {
|
|
|
772
771
|
self.suite = suite;
|
|
773
772
|
self.nextSuite = next;
|
|
774
773
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
} else {
|
|
778
|
-
// mark that the afterAll block has been called once
|
|
779
|
-
// and so can be skipped if there is an error in it.
|
|
780
|
-
afterAllHookCalled = true;
|
|
781
|
-
|
|
782
|
-
// remove reference to test
|
|
783
|
-
delete self.test;
|
|
774
|
+
// remove reference to test
|
|
775
|
+
delete self.test;
|
|
784
776
|
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
}
|
|
777
|
+
self.hook(HOOK_TYPE_AFTER_ALL, function() {
|
|
778
|
+
self.emit(constants.EVENT_SUITE_END, suite);
|
|
779
|
+
fn(errSuite);
|
|
780
|
+
});
|
|
790
781
|
}
|
|
791
782
|
|
|
792
783
|
this.nextSuite = next;
|
|
@@ -800,7 +791,7 @@ Runner.prototype.runSuite = function(suite, fn) {
|
|
|
800
791
|
};
|
|
801
792
|
|
|
802
793
|
/**
|
|
803
|
-
* Handle uncaught exceptions.
|
|
794
|
+
* Handle uncaught exceptions within runner.
|
|
804
795
|
*
|
|
805
796
|
* @param {Error} err
|
|
806
797
|
* @private
|
|
@@ -861,36 +852,24 @@ Runner.prototype.uncaught = function(err) {
|
|
|
861
852
|
|
|
862
853
|
// we cannot recover gracefully if a Runnable has already passed
|
|
863
854
|
// then fails asynchronously
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
// recover from test
|
|
869
|
-
if (runnable.type === constants.EVENT_TEST_BEGIN) {
|
|
870
|
-
this.emit(constants.EVENT_TEST_END, runnable);
|
|
871
|
-
this.hookUp(HOOK_TYPE_AFTER_EACH, this.next);
|
|
872
|
-
return;
|
|
873
|
-
}
|
|
855
|
+
if (runnable.isPassed()) {
|
|
856
|
+
this.fail(runnable, err);
|
|
857
|
+
this.abort();
|
|
858
|
+
} else {
|
|
874
859
|
debug(runnable);
|
|
875
|
-
|
|
876
|
-
// recover from hooks
|
|
877
|
-
var errSuite = this.suite;
|
|
878
|
-
|
|
879
|
-
// XXX how about a less awful way to determine this?
|
|
880
|
-
// if hook failure is in afterEach block
|
|
881
|
-
if (runnable.fullTitle().indexOf('after each') > -1) {
|
|
882
|
-
return this.hookErr(err, errSuite, true);
|
|
883
|
-
}
|
|
884
|
-
// if hook failure is in beforeEach block
|
|
885
|
-
if (runnable.fullTitle().indexOf('before each') > -1) {
|
|
886
|
-
return this.hookErr(err, errSuite, false);
|
|
887
|
-
}
|
|
888
|
-
// if hook failure is in after or before blocks
|
|
889
|
-
return this.nextSuite(errSuite);
|
|
860
|
+
return runnable.callback(err);
|
|
890
861
|
}
|
|
862
|
+
};
|
|
891
863
|
|
|
892
|
-
|
|
893
|
-
|
|
864
|
+
/**
|
|
865
|
+
* Handle uncaught exceptions after runner's end event.
|
|
866
|
+
*
|
|
867
|
+
* @param {Error} err
|
|
868
|
+
* @private
|
|
869
|
+
*/
|
|
870
|
+
Runner.prototype.uncaughtEnd = function uncaughtEnd(err) {
|
|
871
|
+
if (err instanceof Pending) return;
|
|
872
|
+
throw err;
|
|
894
873
|
};
|
|
895
874
|
|
|
896
875
|
/**
|
|
@@ -940,16 +919,12 @@ Runner.prototype.run = function(fn) {
|
|
|
940
919
|
this.on(constants.EVENT_RUN_END, function() {
|
|
941
920
|
debug(constants.EVENT_RUN_END);
|
|
942
921
|
process.removeListener('uncaughtException', uncaught);
|
|
943
|
-
process.on('uncaughtException',
|
|
944
|
-
if (err instanceof Pending) {
|
|
945
|
-
return;
|
|
946
|
-
}
|
|
947
|
-
throw err;
|
|
948
|
-
});
|
|
922
|
+
process.on('uncaughtException', self.uncaughtEnd);
|
|
949
923
|
fn(self.failures);
|
|
950
924
|
});
|
|
951
925
|
|
|
952
926
|
// uncaught exception
|
|
927
|
+
process.removeListener('uncaughtException', self.uncaughtEnd);
|
|
953
928
|
process.on('uncaughtException', uncaught);
|
|
954
929
|
|
|
955
930
|
if (this._delay) {
|
package/mocha.js
CHANGED
|
@@ -1494,7 +1494,10 @@ function Mocha(options) {
|
|
|
1494
1494
|
this.grep(options.grep)
|
|
1495
1495
|
.fgrep(options.fgrep)
|
|
1496
1496
|
.ui(options.ui)
|
|
1497
|
-
.reporter(
|
|
1497
|
+
.reporter(
|
|
1498
|
+
options.reporter,
|
|
1499
|
+
options.reporterOption || options.reporterOptions // reporterOptions was previously the only way to specify options to reporter
|
|
1500
|
+
)
|
|
1498
1501
|
.slow(options.slow)
|
|
1499
1502
|
.global(options.global);
|
|
1500
1503
|
|
|
@@ -5369,9 +5372,18 @@ Runnable.prototype.run = function(fn) {
|
|
|
5369
5372
|
fn(err);
|
|
5370
5373
|
}
|
|
5371
5374
|
|
|
5372
|
-
// for .resetTimeout()
|
|
5375
|
+
// for .resetTimeout() and Runner#uncaught()
|
|
5373
5376
|
this.callback = done;
|
|
5374
5377
|
|
|
5378
|
+
if (this.fn && typeof this.fn.call !== 'function') {
|
|
5379
|
+
done(
|
|
5380
|
+
new TypeError(
|
|
5381
|
+
'A runnable must be passed a function as its second argument.'
|
|
5382
|
+
)
|
|
5383
|
+
);
|
|
5384
|
+
return;
|
|
5385
|
+
}
|
|
5386
|
+
|
|
5375
5387
|
// explicit async with `done` argument
|
|
5376
5388
|
if (this.async) {
|
|
5377
5389
|
this.resetTimeout();
|
|
@@ -6187,7 +6199,7 @@ Runner.prototype.runTests = function(suite, fn) {
|
|
|
6187
6199
|
self.emit(constants.EVENT_TEST_END, test);
|
|
6188
6200
|
// skip inner afterEach hooks below errSuite level
|
|
6189
6201
|
var origSuite = self.suite;
|
|
6190
|
-
self.suite = errSuite;
|
|
6202
|
+
self.suite = errSuite || self.suite;
|
|
6191
6203
|
return self.hookUp(HOOK_TYPE_AFTER_EACH, function(e, eSuite) {
|
|
6192
6204
|
self.suite = origSuite;
|
|
6193
6205
|
next(e, eSuite);
|
|
@@ -6257,7 +6269,6 @@ Runner.prototype.runSuite = function(suite, fn) {
|
|
|
6257
6269
|
var i = 0;
|
|
6258
6270
|
var self = this;
|
|
6259
6271
|
var total = this.grepTotal(suite);
|
|
6260
|
-
var afterAllHookCalled = false;
|
|
6261
6272
|
|
|
6262
6273
|
debug('run suite %s', suite.fullTitle());
|
|
6263
6274
|
|
|
@@ -6305,21 +6316,13 @@ Runner.prototype.runSuite = function(suite, fn) {
|
|
|
6305
6316
|
self.suite = suite;
|
|
6306
6317
|
self.nextSuite = next;
|
|
6307
6318
|
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
} else {
|
|
6311
|
-
// mark that the afterAll block has been called once
|
|
6312
|
-
// and so can be skipped if there is an error in it.
|
|
6313
|
-
afterAllHookCalled = true;
|
|
6314
|
-
|
|
6315
|
-
// remove reference to test
|
|
6316
|
-
delete self.test;
|
|
6319
|
+
// remove reference to test
|
|
6320
|
+
delete self.test;
|
|
6317
6321
|
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
}
|
|
6322
|
+
self.hook(HOOK_TYPE_AFTER_ALL, function() {
|
|
6323
|
+
self.emit(constants.EVENT_SUITE_END, suite);
|
|
6324
|
+
fn(errSuite);
|
|
6325
|
+
});
|
|
6323
6326
|
}
|
|
6324
6327
|
|
|
6325
6328
|
this.nextSuite = next;
|
|
@@ -6333,7 +6336,7 @@ Runner.prototype.runSuite = function(suite, fn) {
|
|
|
6333
6336
|
};
|
|
6334
6337
|
|
|
6335
6338
|
/**
|
|
6336
|
-
* Handle uncaught exceptions.
|
|
6339
|
+
* Handle uncaught exceptions within runner.
|
|
6337
6340
|
*
|
|
6338
6341
|
* @param {Error} err
|
|
6339
6342
|
* @private
|
|
@@ -6394,36 +6397,24 @@ Runner.prototype.uncaught = function(err) {
|
|
|
6394
6397
|
|
|
6395
6398
|
// we cannot recover gracefully if a Runnable has already passed
|
|
6396
6399
|
// then fails asynchronously
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
// recover from test
|
|
6402
|
-
if (runnable.type === constants.EVENT_TEST_BEGIN) {
|
|
6403
|
-
this.emit(constants.EVENT_TEST_END, runnable);
|
|
6404
|
-
this.hookUp(HOOK_TYPE_AFTER_EACH, this.next);
|
|
6405
|
-
return;
|
|
6406
|
-
}
|
|
6400
|
+
if (runnable.isPassed()) {
|
|
6401
|
+
this.fail(runnable, err);
|
|
6402
|
+
this.abort();
|
|
6403
|
+
} else {
|
|
6407
6404
|
debug(runnable);
|
|
6408
|
-
|
|
6409
|
-
// recover from hooks
|
|
6410
|
-
var errSuite = this.suite;
|
|
6411
|
-
|
|
6412
|
-
// XXX how about a less awful way to determine this?
|
|
6413
|
-
// if hook failure is in afterEach block
|
|
6414
|
-
if (runnable.fullTitle().indexOf('after each') > -1) {
|
|
6415
|
-
return this.hookErr(err, errSuite, true);
|
|
6416
|
-
}
|
|
6417
|
-
// if hook failure is in beforeEach block
|
|
6418
|
-
if (runnable.fullTitle().indexOf('before each') > -1) {
|
|
6419
|
-
return this.hookErr(err, errSuite, false);
|
|
6420
|
-
}
|
|
6421
|
-
// if hook failure is in after or before blocks
|
|
6422
|
-
return this.nextSuite(errSuite);
|
|
6405
|
+
return runnable.callback(err);
|
|
6423
6406
|
}
|
|
6407
|
+
};
|
|
6424
6408
|
|
|
6425
|
-
|
|
6426
|
-
|
|
6409
|
+
/**
|
|
6410
|
+
* Handle uncaught exceptions after runner's end event.
|
|
6411
|
+
*
|
|
6412
|
+
* @param {Error} err
|
|
6413
|
+
* @private
|
|
6414
|
+
*/
|
|
6415
|
+
Runner.prototype.uncaughtEnd = function uncaughtEnd(err) {
|
|
6416
|
+
if (err instanceof Pending) return;
|
|
6417
|
+
throw err;
|
|
6427
6418
|
};
|
|
6428
6419
|
|
|
6429
6420
|
/**
|
|
@@ -6473,16 +6464,12 @@ Runner.prototype.run = function(fn) {
|
|
|
6473
6464
|
this.on(constants.EVENT_RUN_END, function() {
|
|
6474
6465
|
debug(constants.EVENT_RUN_END);
|
|
6475
6466
|
process.removeListener('uncaughtException', uncaught);
|
|
6476
|
-
process.on('uncaughtException',
|
|
6477
|
-
if (err instanceof Pending) {
|
|
6478
|
-
return;
|
|
6479
|
-
}
|
|
6480
|
-
throw err;
|
|
6481
|
-
});
|
|
6467
|
+
process.on('uncaughtException', self.uncaughtEnd);
|
|
6482
6468
|
fn(self.failures);
|
|
6483
6469
|
});
|
|
6484
6470
|
|
|
6485
6471
|
// uncaught exception
|
|
6472
|
+
process.removeListener('uncaughtException', self.uncaughtEnd);
|
|
6486
6473
|
process.on('uncaughtException', uncaught);
|
|
6487
6474
|
|
|
6488
6475
|
if (this._delay) {
|
|
@@ -18090,7 +18077,7 @@ function hasOwnProperty(obj, prop) {
|
|
|
18090
18077
|
},{"./support/isBuffer":88,"_process":69,"inherits":56}],90:[function(require,module,exports){
|
|
18091
18078
|
module.exports={
|
|
18092
18079
|
"name": "mocha",
|
|
18093
|
-
"version": "7.0.
|
|
18080
|
+
"version": "7.0.1",
|
|
18094
18081
|
"homepage": "https://mochajs.org/",
|
|
18095
18082
|
"notifyLogo": "https://ibin.co/4QuRuGjXvl36.png"
|
|
18096
18083
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mocha",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "simple, flexible, fun test framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mocha",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"Chris Buckley <chris@cmbuckley.co.uk>",
|
|
106
106
|
"Chris Lamb <chris@chris-lamb.co.uk>",
|
|
107
107
|
"Christian <me@rndm.de>",
|
|
108
|
+
"Christian Holm <christian@peakon.com>",
|
|
108
109
|
"Christoffer Hallas <christoffer.hallas@gmail.com>",
|
|
109
110
|
"Christoph Neuroth <christoph.neuroth@gmail.com>",
|
|
110
111
|
"Christopher Hiller <boneskull@boneskull.com>",
|
|
@@ -291,6 +292,7 @@
|
|
|
291
292
|
"Kunal Nagpal <kunagpal@users.noreply.github.com>",
|
|
292
293
|
"Kyle Fuller <kyle@fuller.li>",
|
|
293
294
|
"Kyle Mitchell <kyle@kemitchell.com>",
|
|
295
|
+
"KyoungWan <kyngwan@gmail.com>",
|
|
294
296
|
"lakmeer <lakmeerkravid@gmail.com>",
|
|
295
297
|
"Lane Kelly <lanekelly16@gmail.com>",
|
|
296
298
|
"László Bácsi <lackac@lackac.hu>",
|
|
@@ -503,6 +505,7 @@
|
|
|
503
505
|
"Yuest Wang <yuestwang@gmail.com>",
|
|
504
506
|
"yuitest <yuitest@cjhat.net>",
|
|
505
507
|
"zhiyelee <zhiyelee@gmail.com>",
|
|
508
|
+
"Zirak <zirakertan@gmail.com>",
|
|
506
509
|
"Zsolt Takács <zsolt@takacs.cc>",
|
|
507
510
|
"现充 <qixiang.cqx@alibaba-inc.com>"
|
|
508
511
|
],
|