diff --git a/lib/nodejs/serializer.js b/lib/nodejs/serializer.js index 25d2e39727..63e1a24e51 100644 --- a/lib/nodejs/serializer.js +++ b/lib/nodejs/serializer.js @@ -259,7 +259,7 @@ class SerializableEvent { }); // mutates the object - breakCircularDeps(result); + breakCircularDeps(result.error); const pairs = Object.keys(result).map(key => [result, key]); diff --git a/test/integration/fixtures/parallel/non-circular-error.mjs b/test/integration/fixtures/parallel/non-circular-error.mjs new file mode 100644 index 0000000000..251a58b0fd --- /dev/null +++ b/test/integration/fixtures/parallel/non-circular-error.mjs @@ -0,0 +1,5 @@ +import {it} from '../../../../index.js'; + +it('test', () => { + throw new Error('Foo'); +}); diff --git a/test/integration/parallel.spec.js b/test/integration/parallel.spec.js index 5dc1d07fcd..fad184e24b 100644 --- a/test/integration/parallel.spec.js +++ b/test/integration/parallel.spec.js @@ -43,4 +43,19 @@ describe('parallel run', () => { assert.strictEqual(result.failures[0].err.message, 'Foo'); assert.strictEqual(result.failures[0].err.foo.props[0], '[Circular]'); }); + + it('should correctly handle an exception with retries', async () => { + const result = await runMochaJSONAsync('parallel/circular-error.mjs', [ + '--parallel', + '--jobs', + '2', + '--retries', + '1', + require.resolve('./fixtures/parallel/testworkerid1.mjs') + ]); + assert.strictEqual(result.stats.failures, 1); + assert.strictEqual(result.stats.passes, 1); + assert.strictEqual(result.failures[0].err.message, 'Foo'); + assert.strictEqual(result.failures[0].err.foo.props[0], '[Circular]'); + }); });