Skip to content

Commit 14be642

Browse files
committed
fix xunit reporter crash when used with parallel mode
1 parent d7ed5c2 commit 14be642

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

lib/hook.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,18 @@ Hook.prototype.error = function(err) {
6262
*/
6363
Hook.prototype.serialize = function serialize() {
6464
return {
65-
$$isPending: this.isPending(),
65+
$$isPending: !!this.isPending(),
6666
$$titlePath: this.titlePath(),
6767
ctx:
6868
this.ctx && this.ctx.currentTest
6969
? {
70-
currentTest: {
71-
title: this.ctx.currentTest.title,
72-
[MOCHA_ID_PROP_NAME]: this.ctx.currentTest.id
73-
}
70+
currentTest: this.ctx.currentTest.serialize()
7471
}
7572
: {},
76-
parent: {
77-
[MOCHA_ID_PROP_NAME]: this.parent.id
78-
},
73+
parent: this.parent.serialize(),
74+
state: this.state,
7975
title: this.title,
8076
type: this.type,
81-
[MOCHA_ID_PROP_NAME]: this.id
77+
[MOCHA_ID_PROP_NAME]: this[MOCHA_ID_PROP_NAME],
8278
};
8379
};

lib/suite.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,11 @@ Suite.prototype.serialize = function serialize() {
594594
return {
595595
_bail: this._bail,
596596
$$fullTitle: this.fullTitle(),
597-
$$isPending: this.isPending(),
597+
$$isPending: !!this.isPending(),
598598
root: this.root,
599599
title: this.title,
600-
id: this.id,
601-
parent: this.parent ? {[MOCHA_ID_PROP_NAME]: this.parent.id} : null
600+
parent: this.parent ? this.parent.serialize() : null,
601+
[MOCHA_ID_PROP_NAME]: this[MOCHA_ID_PROP_NAME],
602602
};
603603
};
604604

lib/test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,19 @@ Test.prototype.serialize = function serialize() {
9292
return {
9393
$$currentRetry: this._currentRetry,
9494
$$fullTitle: this.fullTitle(),
95-
$$isPending: this.pending,
95+
$$isPending: !!this.pending,
9696
$$retriedTest: this._retriedTest || null,
9797
$$slow: this._slow,
9898
$$titlePath: this.titlePath(),
9999
body: this.body,
100100
duration: this.duration,
101101
err: this.err,
102-
parent: {
103-
$$fullTitle: this.parent.fullTitle(),
104-
[MOCHA_ID_PROP_NAME]: this.parent.id
105-
},
102+
parent: this.parent.serialize(),
106103
speed: this.speed,
107104
state: this.state,
108105
title: this.title,
109106
type: this.type,
110107
file: this.file,
111-
[MOCHA_ID_PROP_NAME]: this.id
108+
[MOCHA_ID_PROP_NAME]: this[MOCHA_ID_PROP_NAME],
112109
};
113110
};

0 commit comments

Comments
 (0)