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

🐛 Bug: Errors messages and stack traces from JSDOM loaded scripts are not useful #1757

Closed
mjhm opened this issue Jun 19, 2015 · 7 comments
Labels
type: bug a defect, confirmed by a maintainer

Comments

@mjhm
Copy link

mjhm commented Jun 19, 2015

I put up a test case repo at https://github.com/mjhm/mocha_jsdom_test

As mentioned in the README the repo shows a change in handling jsdom stack traces.

The problem is that for mocha@2.2.X the handling of stack traces has changed so that stack traces of JSDOM loaded scripts are no longer useful.

In particular the report of last test using mocha@2.1.0 is

6) Basic Test with beforeEach jsdom setup throws a jsdom browser error from preloaded file.:
     Error: globalThrower
      at window.browserThrower (file:///Users/johnmclaughlin/git/mocha_jsdom_test/browserThrower.js:5:9)

But the result for mocha@2.2.5 is not useful for tracking down the source of the error:

6) Basic Test with beforeEach jsdom setup throws a jsdom browser error from preloaded file.:
   Error: the error {} was thrown, throw an Error :)
    at Context.jsdomDoneCallback (all_tests.js:12:3)

There are differences in the other tests as well.

  • 1 -- 3 the filtering of mocha@2.2.5 is more helpful than mocha@2.1.0
  • 4 The verbosity of the the mocha@2.1.0 report is arguable more helpful.
  • 5 Although the top line for the reports of the two versions are essentially the same. The mocha@2.1.0 report is somewhat more helpful to track down that this was a callback from jsdom.

Complete test report for mocha@2.2.5:


  Basic Test
    1) throws an error in the actual test
    2) throws an error from a node require
    3) throws an async error from a node require
jsdomDoneCallback: [ { type: 'error',
    message: 'Running file:///Users/johnmclaughlin/git/mocha_jsdom_test2/directThrow.js failed.',
    data: 
     { error: [Error: direct throw from file],
       filename: 'file:///Users/johnmclaughlin/git/mocha_jsdom_test2/directThrow.js' } } ]
    4) throws an error in a jsdom script
    5) throws an error in a jsdom done callback
    with beforeEach jsdom setup
      6) throws a jsdom browser error from preloaded file.


  0 passing (52ms)
  6 failing

  1) Basic Test throws an error in the actual test:
     Error: throws something
      at Context.<anonymous> (all_tests.js:27:11)

  2) Basic Test throws an error from a node require:
     Error: thrower
      at module.exports (thrower.js:3:9)
      at Context.<anonymous> (all_tests.js:31:5)

  3) Basic Test throws an async error from a node require:
     Uncaught Error: thrower
      at module.exports (thrower.js:3:9)
      at null._onTimeout (all_tests.js:36:7)

  4) Basic Test throws an error in a jsdom script:
     the object {
  "data": {
    "error": "Error: direct throw from file"
    "filename": "file:///Users/johnmclaughlin/git/mocha_jsdom_test2/directThrow.js"
  }
  "message": "Running file:///Users/johnmclaughlin/git/mocha_jsdom_test2/directThrow.js failed."
  "type": "error"
  "uncaught": true
} was thrown, throw an Error :)
  Error: the object {
    "data": {
      "error": "Error: direct throw from file"
      "filename": "file://directThrow.js"
    }
    "message": "Running file://directThrow.js failed."
    "type": "error"
    "uncaught": true
  } was thrown, throw an Error :)

  5) Basic Test throws an error in a jsdom done callback:
     Uncaught Error: thrower
      at Object.module.exports [as done] (thrower.js:3:9)

  6) Basic Test with beforeEach jsdom setup throws a jsdom browser error from preloaded file.:
     Error: the error {} was thrown, throw an Error :)
      at Context.jsdomDoneCallback (all_tests.js:12:3)

Complete test report for mocha@2.1.0


  Basic Test
    1) throws an error in the actual test
    2) throws an error from a node require
    3) throws an async error from a node require
jsdomDoneCallback: [ { type: 'error',
    message: 'Running file:///Users/johnmclaughlin/git/mocha_jsdom_test2/directThrow.js failed.',
    data: 
     { error: [Error: direct throw from file],
       filename: 'file:///Users/johnmclaughlin/git/mocha_jsdom_test2/directThrow.js' } } ]
    4) throws an error in a jsdom script
    5) throws an error in a jsdom done callback
    with beforeEach jsdom setup
      6) throws a jsdom browser error from preloaded file.


  0 passing (48ms)
  6 failing

  1) Basic Test throws an error in the actual test:
     Error: throws something
      at Context.<anonymous> (/Users/johnmclaughlin/git/mocha_jsdom_test2/all_tests.js:27:11)
      at callFn (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runnable.js:251:21)
      at Test.Runnable.run (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runnable.js:244:7)
      at Runner.runTest (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:374:10)
      at /Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:452:12
      at next (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:299:14)
      at /Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:309:7
      at next (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:248:23)
      at Immediate._onImmediate (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:276:5)
      at processImmediate [as _immediateCallback] (timers.js:358:17)

  2) Basic Test throws an error from a node require:
     Error: thrower
      at module.exports (/Users/johnmclaughlin/git/mocha_jsdom_test2/thrower.js:3:9)
      at Context.<anonymous> (/Users/johnmclaughlin/git/mocha_jsdom_test2/all_tests.js:31:5)
      at callFn (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runnable.js:251:21)
      at Test.Runnable.run (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runnable.js:244:7)
      at Runner.runTest (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:374:10)
      at /Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:452:12
      at next (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:299:14)
      at /Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:309:7
      at next (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:248:23)
      at Immediate._onImmediate (/Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/mocha/lib/runner.js:276:5)
      at processImmediate [as _immediateCallback] (timers.js:358:17)

  3) Basic Test throws an async error from a node require:
     Uncaught Error: thrower
      at module.exports (/Users/johnmclaughlin/git/mocha_jsdom_test2/thrower.js:3:9)
      at null._onTimeout (/Users/johnmclaughlin/git/mocha_jsdom_test2/all_tests.js:36:7)
      at Timer.listOnTimeout (timers.js:110:15)

  4) Basic Test throws an error in a jsdom script:
     Uncaught Running file:///Users/johnmclaughlin/git/mocha_jsdom_test2/directThrow.js failed.


  5) Basic Test throws an error in a jsdom done callback:
     Uncaught Error: thrower
      at Object.module.exports [as done] (/Users/johnmclaughlin/git/mocha_jsdom_test2/thrower.js:3:9)
      at /Users/johnmclaughlin/git/mocha_jsdom_test2/node_modules/jsdom/lib/jsdom.js:249:18
      at process._tickCallback (node.js:355:11)

  6) Basic Test with beforeEach jsdom setup throws a jsdom browser error from preloaded file.:
     Error: globalThrower
      at window.browserThrower (file:///Users/johnmclaughlin/git/mocha_jsdom_test2/browserThrower.js:5:9)


@mjhm mjhm changed the title Errors generated from JSDOM loaded scripts are no longer useful in mocha@2.2.X Errors messages and stack traces from JSDOM loaded scripts are no longer useful in mocha@2.2.X Jun 21, 2015
@danielstjules
Copy link
Contributor

Seems related to #1766 Can you checkout #1767 and confirm whether or not it helps?

@mjhm
Copy link
Author

mjhm commented Jun 28, 2015

@danielstjules In my test case it looks like #1767 prints out pretty much the same as the --full-trace option with mocha@2.2.5. Unfortunately this still misses the stack trace lines for the JSDOM loaded files.

Output for #1767


  1) Basic Test throws an error in the actual test:
     Error: throws something
      at Context.<anonymous> (/Users/johnmclaughlin/git/mocha_jsdom_test/all_tests.js:27:11)
      at callFn (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runnable.js:266:21)
      at Test.Runnable.run (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runnable.js:259:7)
      at Runner.runTest (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:390:10)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:473:12
      at next (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:315:14)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:325:7
      at next (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:260:23)
      at Immediate._onImmediate (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:292:5)
      at processImmediate [as _immediateCallback] (timers.js:358:17)

  2) Basic Test throws an error from a node require:
     Error: thrower
      at module.exports (/Users/johnmclaughlin/git/mocha_jsdom_test/thrower.js:3:9)
      at Context.<anonymous> (/Users/johnmclaughlin/git/mocha_jsdom_test/all_tests.js:31:5)
      at callFn (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runnable.js:266:21)
      at Test.Runnable.run (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runnable.js:259:7)
      at Runner.runTest (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:390:10)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:473:12
      at next (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:315:14)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:325:7
      at next (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:260:23)
      at Immediate._onImmediate (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:292:5)
      at processImmediate [as _immediateCallback] (timers.js:358:17)

  3) Basic Test throws an async error from a node require:
     Uncaught Error: thrower
      at module.exports (/Users/johnmclaughlin/git/mocha_jsdom_test/thrower.js:3:9)
      at null._onTimeout (/Users/johnmclaughlin/git/mocha_jsdom_test/all_tests.js:36:7)
      at Timer.listOnTimeout (timers.js:110:15)

  4) Basic Test throws an error in a jsdom script:
     Error: the object {
  "data": {
    "error": "Error: direct throw from file"
    "filename": "file:///Users/johnmclaughlin/git/mocha_jsdom_test/directThrow.js"
  }
  "message": "Running file:///Users/johnmclaughlin/git/mocha_jsdom_test/directThrow.js failed."
  "type": "error"
  "uncaught": true
} was thrown, throw an Error :)
      at Runner.fail (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:206:11)
      at Runner.uncaught (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:583:8)
      at process.uncaught (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:612:10)
      at process.emit (events.js:107:17)
      at process._fatalException (node.js:236:26)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/jsdom/lib/jsdom.js:249:18
      at process._tickCallback (node.js:355:11)

  5) Basic Test throws an error in a jsdom done callback:
     Uncaught Error: thrower
      at Object.module.exports [as done] (/Users/johnmclaughlin/git/mocha_jsdom_test/thrower.js:3:9)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/jsdom/lib/jsdom.js:249:18
      at process._tickCallback (node.js:355:11)

  6) Basic Test with beforeEach jsdom setup throws a jsdom browser error from preloaded file.:
     Error: the error {} was thrown, throw an Error :)
      at Runner.fail (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:206:11)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:480:18
      at done (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runnable.js:222:5)
      at Test.Runnable.run (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runnable.js:245:7)
      at Runner.runTest (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:390:10)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:473:12
      at next (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:315:14)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:325:7
      at next (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:260:23)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runner.js:287:7
      at done (/Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runnable.js:222:5)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/mocha/lib/runnable.js:242:9
      at Context.jsdomDoneCallback (/Users/johnmclaughlin/git/mocha_jsdom_test/all_tests.js:12:3)
      at /Users/johnmclaughlin/git/mocha_jsdom_test/node_modules/jsdom/lib/jsdom.js:249:18
      at process._tickCallback (node.js:355:11)

@boneskull boneskull added the type: bug a defect, confirmed by a maintainer label Jul 10, 2015
@boneskull
Copy link
Contributor

@danielstjules I'm gonna put this on your plate 😄

@danielstjules
Copy link
Contributor

@boneskull haha cool, will take a look this weekend

@czardoz
Copy link

czardoz commented Mar 29, 2016

Any updates on this? 😄

@stale
Copy link

stale bot commented Oct 17, 2017

I am a bot that watches issues for inactivity.
This issue hasn't had any recent activity, and I'm labeling it stale. In 14 days, if there are no further comments or activity, I will close this issue.
Thanks for contributing to Mocha!

@stale stale bot added the stale this has been inactive for a while... label Oct 17, 2017
@boneskull boneskull added status: accepting prs Mocha can use your help with this one! and removed stale this has been inactive for a while... labels Oct 17, 2017
@JoshuaKGoldberg JoshuaKGoldberg removed the status: accepting prs Mocha can use your help with this one! label Dec 27, 2023
@JoshuaKGoldberg JoshuaKGoldberg changed the title Errors messages and stack traces from JSDOM loaded scripts are no longer useful in mocha@2.2.X 🐛 Bug: Errors messages and stack traces from JSDOM loaded scripts are no longer useful in mocha@2.2.X Dec 27, 2023
@JoshuaKGoldberg JoshuaKGoldberg changed the title 🐛 Bug: Errors messages and stack traces from JSDOM loaded scripts are no longer useful in mocha@2.2.X 🐛 Bug: Errors messages and stack traces from JSDOM loaded scripts are not useful Dec 27, 2023
@JoshuaKGoldberg
Copy link
Member

This should have been fixed in #1767. Also the issue is very old and hasn't been interacted with since 2017. Marking as closed. ✔️

But if I'm wrong and it's still an active issue, please do file a new issue using one of our new issue templates. They'll ask for the info we'd need to re-triage this. Cheers all!

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

5 participants