How to include one CoffeeScript file in another in order to share specs amongst jasmine

a 夏天 提交于 2020-01-17 05:24:16

问题


I'm unable to get CoffeeScript in Jasmine to include another file. I'd like to share common functions amongst Jasmine specs which are written in CoffeeScript.

I'm sure I'm getting the syntax wrong, I've tried require and include, I've tried putting the file in the same folder just to be sure, I've tried # = syntax too.

I'm looking for something similar to include in php, i.e. go here -> compile this -> come back so the compile this step can easily be shared.

NB, I am not talking about inclusion in the compiled source, but inclusion before / during the compile step - I am also running these scripts as part of a Jasmine / Evergreen setup, accessing the URL in the browser.


回答1:


What you're looking for is a build system, which Coffeescript is not. Coffeescript can translate the syntax of a single file only into plain Javascript, it does not concern itself with concatenating or bundling additional external resources. There are a metric ton of Javascript build systems which can inline require calls; personally I'm very happy with Duo at the moment, but Grunt is the de facto kitchen sink in Javascript build systems, so have a look at both and others.



来源:https://stackoverflow.com/questions/32518302/how-to-include-one-coffeescript-file-in-another-in-order-to-share-specs-amongst

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!