diff --git a/src/register.js b/src/register.js index 10966ad..7566b5b 100644 --- a/src/register.js +++ b/src/register.js @@ -26,7 +26,10 @@ const serializeHook = hook => { } const serializeTest = test => { - return serializeObject(test, ['pending', 'context']); + const result = serializeObject(test, ['pending', 'context']); + // to remove a circular dependency: https://github.com/adamgruber/mochawesome/issues/356 + result["$$retriedTest"] = null; + return result; } const serializeObject = (obj, fields) => { diff --git a/test-functional/.mocharc.json b/test-functional/.mocharc.json index 37ed19e..58f1883 100644 --- a/test-functional/.mocharc.json +++ b/test-functional/.mocharc.json @@ -1,5 +1,6 @@ { "require": ["should", "./register"], "reporter": "./src/mochawesome", - "reporterOption": [] + "reporterOption": [], + "retries": 1 } diff --git a/test/parallel-mode.test.js b/test/parallel-mode.test.js index 6c43b0f..21e2c83 100644 --- a/test/parallel-mode.test.js +++ b/test/parallel-mode.test.js @@ -216,6 +216,27 @@ describe('Parallel Mode', () => { fake: true }); }); + + it(`should ignore the retriedTest to avoid circular serialization issue`, () => { + // arrange + const given = { + testName: 'FAKE TEST', + retriedName: 'RETRIED TEST', + suiteName: 'FAKE SUITE', + error: Object.assign(new Error("FAKE ERROR"), { fake: true }) + }; + const test = new Test(given.testName, noop); + test.parent = new Suite(given.suiteName); + test.retriedTest(new Test(given.retriedName, noop)) + + // act + const actual = serializeTest(test); + + // assert + actual.should.containDeep({ + "$$retriedTest": null + }); + }); }); describe("serializeError()", () => {