You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The summary of the linked issue is that endSuite might be called without a matching startSuite if a describe is used that has no tests. This can happen when dynamically generating its.
I'm not sure if it is strictly necessary for hooks to always be called pairwise (start + end) but it makes coding any state dependent hooks much easier.
Here is the diff that solved my problem:
diff --git a/node_modules/mocha/lib/runner.js b/node_modules/mocha/lib/runner.js
index 60a19f0..9103d9b 100644
--- a/node_modules/mocha/lib/runner.js+++ b/node_modules/mocha/lib/runner.js@@ -854,14 +854,13 @@ Runner.prototype.runSuite = function (suite, fn) {
var total = this.grepTotal(suite);
debug('runSuite(): running %s', suite.fullTitle());
+ this.emit(constants.EVENT_SUITE_BEGIN, (this.suite = suite));
if (!total || (self.failures && suite._bail)) {
debug('runSuite(): bailing');
return fn();
}
- this.emit(constants.EVENT_SUITE_BEGIN, (this.suite = suite));-
function next(errSuite) {
if (errSuite) {
// current suite failed on a hook from errSuite
@@ -903,6 +902,7 @@ Runner.prototype.runSuite = function (suite, fn) {
// remove reference to test
delete self.test;
+ debug('done(): ending %s', suite.fullTitle());
self.hook(HOOK_TYPE_AFTER_ALL, function () {
self.emit(constants.EVENT_SUITE_END, suite);
fn(errSuite);
Interesting find! Could you / someone please post an isolated reproduction we can take a look at here? One that doesn't require knowing other downstream tools like webdriverio. Thanks!
I'm creating this ticket due to ticket webdriverio/webdriverio#13013
The summary of the linked issue is that
endSuite
might be called without a matchingstartSuite
if adescribe
is used that has no tests. This can happen when dynamically generatingit
s.I'm not sure if it is strictly necessary for hooks to always be called pairwise (start + end) but it makes coding any state dependent hooks much easier.
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: