如何在另一个中包含一个CoffeeScript文件,以便在茉莉花中共享规格 [英] How to include one CoffeeScript file in another in order to share specs amongst jasmine

查看:238
本文介绍了如何在另一个中包含一个CoffeeScript文件,以便在茉莉花中共享规格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在Jasmine中获取CoffeeScript以包含其他文件。

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.

我确定我的语法错误,我试过 require include ,我试过把文件放在同一个文件夹,

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.

我正在寻找类似的东西包含在php,即 go here - >编译这个 - >回来,因此编译此步骤可以轻松共享。

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.

不是在编译源代码中包含,而是在编译步骤之前/期间包含 - 我也将这些脚本作为Jasmine / Evergreen设置的一部分运行, p>

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.

推荐答案

您正在寻找的是一个构建系统,Coffeescript不是。 Coffeescript可以将单个文件的语法仅转换为简单的Javascript,它不关心连接或捆绑额外的外部资源。有大量的Javascript构建系统可以内联 require 调用;目前,我对 Duo 非常满意,但 Grunt 是JavaScript构建系统中的事实上的厨房水槽,所以请看看这两个和其他人。

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.

这篇关于如何在另一个中包含一个CoffeeScript文件,以便在茉莉花中共享规格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆