import * as chai from 'chai';
const e = new Error('hello');
e.cause = e;
chai.expect(e).to.equal(123);
// Error: Maximum call stack size exceeded
For the context, we're thinking to expand on Error equality on Vitest https://github.com/vitest-dev/vitest/pull/5876. Most of the logic is implemented on Vitest side, but we still use chai's assertion error message generation. While making test cases with cyclic references, I found that Error: Maximum call stack size exceeded is likely coming from chai as seen in the repro above.
chai: 5.1.1 reproduction: https://stackblitz.com/edit/github-caqski-bm1zja?file=repro.mjs
For the context, we're thinking to expand on Error equality on Vitest https://github.com/vitest-dev/vitest/pull/5876. Most of the logic is implemented on Vitest side, but we still use chai's assertion error message generation. While making test cases with cyclic references, I found that
Error: Maximum call stack size exceeded
is likely coming from chai as seen in the repro above.