Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Copy Suite property "root" when cloning; closes #3847 (#3848)

Carl-Erik Kopseng81cfa9072b79
diff --git a/lib/suite.js b/lib/suite.js
index 6d1d0fb5..191d946b 100644
--- a/lib/suite.js
+++ b/lib/suite.js
@@ -102,6 +102,7 @@ Suite.prototype.clone = function() {
var suite = new Suite(this.title);
debug('clone');
suite.ctx = this.ctx;
+ suite.root = this.root;
suite.timeout(this.timeout());
suite.retries(this.retries());
suite.enableTimeouts(this.enableTimeouts());
diff --git a/test/unit/suite.spec.js b/test/unit/suite.spec.js
index 2a1d639c..1be948e1 100644
--- a/test/unit/suite.spec.js
+++ b/test/unit/suite.spec.js
@@ -23,7 +23,7 @@ describe('Suite', function() {
describe('.clone()', function() {
beforeEach(function() {
- this.suite = new Suite('To be cloned');
+ this.suite = new Suite('To be cloned', {}, true);
this.suite._timeout = 3043;
this.suite._slow = 101;
this.suite._bail = true;
@@ -74,6 +74,10 @@ describe('Suite', function() {
it('should not copy the values from the _afterAll array', function() {
expect(this.suite.clone()._afterAll, 'to be empty');
});
+
+ it('should copy the root property', function() {
+ expect(this.suite.clone().root, 'to be', true);
+ });
});
describe('.timeout()', function() {