我在这个文件夹结构的项目中使用node
0.8与jasmine-node
,coffee-script
和backbone
:和奇怪`require`在茉莉节点行为
<project root>
` fares/
| ` base.coffee
| ` import.coffee
| ` import_list.coffee
` spec/
` fares/
` base.spec.coffee
` import_list.spec.coffee
我有绿测试时的怪异情况从特定的文件夹中调用并从另一个文件夹中进行红色测试
如果我运行:
jasmine-node --coffee spec/fares/import_list.spec.coffee
测试通过。但是,如果我运行整个套件:
jasmine-node --coffee spec/
测试失败。
检查发生故障的日志,其中console.log
编辑require "./import"
的结果,发现它是空对象({}
)而不是Import类。
我不知道为什么会发生这种情况,你对这种奇怪的行为有任何线索吗?感谢您的帮助,谢谢。
The gist with all the code and logs is in here。
阅读此答案,它可能会帮助你,http://stackoverflow.com/questions/15471965/what-will-be-the-difference-in-requiremypackage-js-and-requiremypackage/15471995#15471995 – 2013-03-26 05:26:57