How to track down what is causing a timeout?

coffeescript, mocha.js, node.js

Solution

I'd try changing your reporter. I use

`mocha --compilers coffee:coffee-script *.coffee --ui bdd -d --watch -R Nyan` and get traces about 20 lines long when I have a failure.

Timeouts usually mean (I've never seen it otherwise) that your `done()` is not getting hit. I suspect one of these two:

`Testing.initialUsers -> Testing.clearResultData ->`

is not calling its callback.

Problem

I am using Mocha to run a number of tests. When I get to one particular set of tests: ``` describe "Results Summaries", -> before (done) -> Testing.use("surveyplanet_test") Testing.initialUsers -> Testing.clearResultData -> done() beforeEach (done) -> Testing.redis.flushdb -> done() describe "Multiple Choice", -> describe "Standard Choice Selection", -> before (done) -> Testing.clearResultData -> Testing.loadQuestion "standardMC", -> Testing.loadExportData data: summarydata.standardMC onComplete: done describe "Pre-Summarization", -> before (done) -> answer_data = {} Testing.getMultipleTables tables: ["answers_main"] onComplete: (data) -> answer_data = data done() ``` It throws the error: Results Summaries 1) "before all" hook ✖ 1 of 340 tests failed: 1) Results Summaries "before all" hook: Error: timeout of 2000ms exceeded at Object. (/usr/local/lib/node_modules/mocha/lib/runnable.js:142:14) at Timer.list.ontimeout (timers.js:101:19) Is there any way to get a stack trace for the piece of my code that threw the error?

Original source