[英]Mocha testing throws AssertionError
I'm working on a simple testing scripts with mocha and coffeescript. 我正在使用Mocha和coffeescript开发一个简单的测试脚本。
In my test folder, I have a configuration for mocha( mocha.opts ): 在我的测试文件夹中,我有一个用于mocha的配置( mocha.opts ):
--compilers coffee: coffee-script/register
--reporter spec
And my testing file ( test_one.coffee ): 和我的测试文件( test_one.coffee ):
assert = require "assert"
describe "A feature", ->
describe "An specific function", ->
it "Should work as expected", ->
assert true
But whenever I run "mocha ." 但是每当我运行“ mocha”时。 it returns me this: 它返回我:
assert.js:93
throw new assert.AssertionError({
AssertionError: missing path
at Module.require (module.js:363:3)
at require (module.js:380:17)
at args (C:\...\AppData\Roaming\npm\node_modules\mocha\bi
at Array.forEach (native)
at Object.<anonymous> (C:\...\AppData\Roaming\npm\node_mo
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:929:3
Any ideas of how can I fix this? 关于如何解决此问题的任何想法?
The option to pass to Mocha is: --compilers coffee:coffee-script/register
. 传递给Mocha的选项是:-- --compilers coffee:coffee-script/register
。 Note the lack of space after the colon. 注意冒号后的空间不足。
I believe what is happening is that with the space, it tells Mocha that to compile coffee
files, it should load a module with a path which is an empty string, and you get the error you get. 我相信正在发生的事情是,该空间告诉Mocha要编译coffee
文件,它应该使用路径为空字符串的方式加载模块,并且您会收到错误消息。
As a reference for anyone looking for this error. 作为寻找此错误的任何人的参考。
This is almost always an error in the string passed in package.json
mine was: 在package.json
我传递的字符串中,这几乎总是错误:
"test": "mocha --reporter spec --compilers ts:ts-node/register, 'test/**/*.test.ts'"
Notice the comma after the word register 注意单词注册后的逗号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.