-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Mocha 2.3.4: Errors That Occur Outside of beforeEach
/it
in an AMD Module Lose Stack Trace
#2167
Comments
I am a bot that watches issues for inactivity. |
closing, since outdated Mocha version and AMD modules. |
4 tasks
Re-filed in #5106. |
#5107 is merged; we'll release a new version with the fix soon. 🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Short Version: If an error occurs inside a Mocha function inside an AMD module, but not inside a Mocha function that expects errors (eg.
it
), the stack trace of the error somehow gets eaten.Reproduction Steps:
Step 1: npm install mocha
Step 2: create
testMain.js
(ie. a file which does nothing but use Require.js to importtestFoo.js
):Step 3: create
testFoo.js
(ie. a simple test file with errors thrown in unexpected places)Step 4: run
mocha testMain.js
; you will get the following output (without a stack trace):NOTE 1: The stack trace is also lost if you comment out error "a" and make it to error "b"
NOTE 2: The stack trace is NOT lost if you comment out the first two errors and make it to error "c".
NOTE 3: The stack trace is also not lost if you throw a new error before the mocha code starts (ie. if you
throw new Error('d')
before thedefine
).Obviously it's very hard to debug a problem when this happens (you have to resort to "delete debugging", ie. removing random chunks of modified code until the error goes away), so if there's any way Mocha could provide a stack trace under these conditions it would be very helpful.
P.S. I suppose one could argue that this is a Require.js problem, not a Mocha problem. However, the fact that everything works as expected outside Mocha in an AMD environment, or inside an AMD environment inside an
it
/after
/beforeEach
/etc., but not inside the other Mocha functions, suggests that Mocha is doing something in those functions that's the root cause of the issue (even though Requirejs/AMD does seem to be a key component).The text was updated successfully, but these errors were encountered: