From 9e0369b03475d0cc4ffbd32523bdf95b287fe9b7 Mon Sep 17 00:00:00 2001 From: Curtis Man Date: Thu, 26 Aug 2021 00:35:29 -0700 Subject: [PATCH] fix(parallel): 'XUNIT' and 'JSON' reporter crash (#4623) --- lib/hook.js | 8 +++++++- lib/suite.js | 4 ++-- lib/test.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/hook.js b/lib/hook.js index 890086fad2..a246d053d1 100644 --- a/lib/hook.js +++ b/lib/hook.js @@ -62,7 +62,9 @@ Hook.prototype.error = function(err) { */ Hook.prototype.serialize = function serialize() { return { - $$isPending: this.isPending(), + $$currentRetry: this.currentRetry(), + $$fullTitle: this.fullTitle(), + $$isPending: Boolean(this.isPending()), $$titlePath: this.titlePath(), ctx: this.ctx && this.ctx.currentTest @@ -73,9 +75,13 @@ Hook.prototype.serialize = function serialize() { } } : {}, + duration: this.duration, + file: this.file, parent: { + $$fullTitle: this.parent.fullTitle(), [MOCHA_ID_PROP_NAME]: this.parent.id }, + state: this.state, title: this.title, type: this.type, [MOCHA_ID_PROP_NAME]: this.id diff --git a/lib/suite.js b/lib/suite.js index 2f16b2f5f6..e3a63bbbf8 100644 --- a/lib/suite.js +++ b/lib/suite.js @@ -594,10 +594,10 @@ Suite.prototype.serialize = function serialize() { return { _bail: this._bail, $$fullTitle: this.fullTitle(), - $$isPending: this.isPending(), + $$isPending: Boolean(this.isPending()), root: this.root, title: this.title, - id: this.id, + [MOCHA_ID_PROP_NAME]: this.id, parent: this.parent ? {[MOCHA_ID_PROP_NAME]: this.parent.id} : null }; }; diff --git a/lib/test.js b/lib/test.js index f2be51b4f4..fc5f8727e7 100644 --- a/lib/test.js +++ b/lib/test.js @@ -92,7 +92,7 @@ Test.prototype.serialize = function serialize() { return { $$currentRetry: this._currentRetry, $$fullTitle: this.fullTitle(), - $$isPending: this.pending, + $$isPending: Boolean(this.pending), $$retriedTest: this._retriedTest || null, $$slow: this._slow, $$titlePath: this.titlePath(),