Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Commit 4d9bc62

Browse files
fix: suite clone does not clone fullUrl
1 parent d1fda4a commit 4d9bc62

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

lib/runner/browser-runner/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = class BrowserRunner extends Runner {
3030
.map((suite) => {
3131
if (suite.hasOwnProperty('url')) {
3232
Object.defineProperty(suite, 'fullUrl', {
33+
enumerable: true,
3334
get: () => this._mkFullUrl(suite.url)
3435
});
3536
}

lib/suite.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ module.exports = class Suite {
8484
const clonedSuite = Suite.create(this.name, this.parent);
8585

8686
_.forOwn(this, (value, key) => {
87-
clonedSuite[key] = _.clone(value);
87+
let desc = Object.getOwnPropertyDescriptor(this, key);
88+
Object.defineProperty(clonedSuite, key, _.cloneDeep(desc));
8889
});
8990

9091
this.children.forEach((child) => clonedSuite.addChild(child.clone()));

test/unit/suite.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,26 @@ describe('suite', () => {
342342

343343
it('should return cloned suite', () => {
344344
const suite = createSuite('origin');
345+
suite.browsers = ['bro1', 'bro2'];
345346
const clonedSuite = suite.clone();
346347

347-
assert.notEqual(clonedSuite, suite);
348+
assert.deepEqual(clonedSuite, suite);
349+
assert.notEqual(clonedSuite, suite); //not equal by link
350+
assert.notEqual(clonedSuite.browsers, suite.browsers); //not equal by link
351+
});
352+
353+
it('should clone all enumerable properties', () => {
354+
const suite = createSuite('origin');
355+
let value = 'some/path';
356+
Object.defineProperty(suite, 'fullUrl', {
357+
enumerable: true,
358+
get: () => value
359+
});
360+
const clonedSuite = suite.clone();
361+
362+
assert.equal(clonedSuite.fullUrl, 'some/path');
363+
value = 'another/path';
364+
assert.equal(clonedSuite.fullUrl, 'another/path');
348365
});
349366

350367
it('should clone nested suites', () => {

0 commit comments

Comments
 (0)