本文介绍了有没有办法将外部Javascript作为Jasmine的源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将jasmine.yml(使用jasmine gem)配置为使用Google API提供的JQuery,而不是将其本地下载到我的服务器.即:

I am trying to configure jasmine.yml (using jasmine gem) to use JQuery served from Google API instead of downloading it locally to my server. I.e.:

src_files:
  - ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js

不幸的是,这似乎不起作用,因为(根据配置文件中的注释)它正在寻找相对于src_dir的文件路径.那不可能吗?

Unfortunately this does not seem to work, since (as per the comments in the config file) it is looking for filepaths relative to src_dir. Is this not possible then?

谢谢

Ruy

推荐答案

我最终通过spec helper编写了javascript include-就我而言,是Livereload脚本:

I ended up writing the javascript include via spec helper - in my case the Livereload script:

document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>');

有点笨拙,但可以使用.您可能想更准确地定义脚本的插入位置.

It’s a bit hacky but works. You might want to define more accurately where the script is being inserted.

这篇关于有没有办法将外部Javascript作为Jasmine的源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 01:01