Skip to content

🐛 Bug: Calling done with circular reference object results in type error converting JSON instead of correct failure message #2598

Open

Description

Just spent way too long getting this bug and not knowing why. After figuring it out, here's the simplest repro I could make

it('Mocha is confused', function(done) {
  new Promise(function(resolve, reject) {
    var a = {};
    a.b = a;
    resolve(a);
  }).then(done).catch(done);
});

Produces

  1) Mocha is confused

  0 passing (20ms)
  1 failing

  1)  Mocha is confused:
     TypeError: Converting circular structure to JSON
      at Object.stringify (native)

The problem here is that there isn't a stack-trace, so I start off with absolutely no idea how to solve the problem. I have no idea why Mocha wants to stringify what I give to the done function, but it does...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area: reportersinvolving a specific reporterstatus: accepting prsMocha can use your help with this one!type: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions