Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leak detection overwrites test error (OR: subsequent errors can clobber prior in report?) #2971

Closed
ScottFreeCode opened this issue Aug 28, 2017 · 2 comments
Labels
type: bug a defect, confirmed by a maintainer

Comments

@ScottFreeCode
Copy link
Contributor

ScottFreeCode commented Aug 28, 2017

Run this test file with --check-leaks:

it("leak issue", function() {
  leaky = true
  throw new Error("And also fail the test")
})

You should get one error "And also fail the test" and another "Error: global leak detected: leaky" (or perhaps, if not both, then only one or the other). Instead you get two of the latter.

I'd guess that the error property on the failed test is being overwritten and an extra fail event emitted for that test, instead of generating a fail event associated with the test but with its own error property.

@ScottFreeCode ScottFreeCode added type: bug a defect, confirmed by a maintainer confirmed labels Aug 31, 2017
@ScottFreeCode ScottFreeCode changed the title leak detection overwrites test error leak detection overwrites test error (OR: subsequent errors can clobber prior in report?) Nov 7, 2017
@ScottFreeCode
Copy link
Contributor Author

This is probably just a specific case of a general issue with errors overwriting prior errors, see e.g. the way "second" is reported twice instead of "first" and "second" in #2906.

@juergba
Copy link
Contributor

juergba commented Nov 21, 2019

This issue was fixed with #4033.

  1) leak issue
  2) leak issue

  0 passing (26ms)
  2 failing

  1) leak issue:
     Error: And also fail the test
      at Context.<anonymous> (D:\mocha-fork\errorCode.js:72:9)
      [...]      

  2) leak issue:
     Error: global leak detected: 'leaky'
      at Runner.checkGlobals (lib\runner.js:273:17)
      [...]

@juergba juergba closed this as completed Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants