如果testing失败,如何让Mocha在源文件中显示正确的行号?

我正在使用Mocha进行NodeJStesting,当由于源代码抛出错误而导致testing失败时(例如“ TypeError: Cannot read property 'prop' of null ”),显示的堆栈跟踪中的行号是错误的(它们与原始源文件不匹配,但是更大)。

  1) MyApp should do something: TypeError: Cannot read property 'prop' of null at MyApp.<anonymous> (/path/to/my-project/lib/my-project.js:515:93) at MyApp.build (/path/to/my-project/lib/my-project.js:774:16) at Context.<anonymous> (/path/to/my-project/test/test.js:62:67) at Test.Runnable.run (/path/to/my-project/node_modules/mocha/lib/runnable.js:216:15) at Runner.runTest (/path/to/my-project/node_modules/mocha/lib/runner.js:373:10) at /path/to/my-project/node_modules/mocha/lib/runner.js:451:12 at next (/path/to/my-project/node_modules/mocha/lib/runner.js:298:14) at /path/to/my-project/node_modules/mocha/lib/runner.js:308:7 at next (/path/to/my-project/node_modules/mocha/lib/runner.js:246:23) at Object._onImmediate (/path/to/my-project/node_modules/mocha/lib/runner.js:275:5) at processImmediate [as _immediateCallback] (timers.js:330:15) 

(这里my-project.js只有279行!)

有没有办法告诉摩卡正确显示它们?

       

网上收集的解决方案 "如果testing失败,如何让Mocha在源文件中显示正确的行号?"