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

后端 未结 5 2146
名媛妹妹
名媛妹妹 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:21

    Use the debug lib.

    import debug from 'debug'
    const log = debug('server');
    

    Use it:

    log('holi')
    

    then run:

    DEBUG=server npm test
    

    And that's it!

提交回复
热议问题