Testing javascript with Mocha - how can I use console.log to debug a test?

后端 未结 5 2160
名媛妹妹
名媛妹妹 2020-12-13 16:31

I am using the javascript test-runner \"Mocha\".

I have a test that is failing, so I would to debug it using console.log.

But when the tests are

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 17:33

    What Mocha options are you using?

    Maybe it is something to do with reporter (-R) or ui (-ui) being used?

    console.log(msg);
    

    works fine during my test runs, though sometimes mixed in a little goofy. Presumably due to the async nature of the test run.

    Here are the options (mocha.opts) I'm using:

    --require should
    -R spec
    --ui bdd
    

    Hmm..just tested without any mocha.opts and console.log still works.

提交回复
热议问题