Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track down what is causing a timeout?

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?

like image 239
Abe Miessler Avatar asked Dec 18 '12 20:12

Abe Miessler


1 Answers

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.

like image 167
jcollum Avatar answered Sep 18 '22 15:09

jcollum