茉莉花jQuery夹具不加载 [英] jasmine-jquery fixtures not loading

查看:79
本文介绍了茉莉花jQuery夹具不加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是 jasmine-jquery 无法从 spec/fixtures 文件夹加载我的灯具.现在,当我查看jasmine-jquery源代码时,灯具的默认路径为 spec/javascripts/fixtures . 在我拥有的版本中,没有 spec/javascripts/fixtures 文件夹.看来这对于Ruby gem是有用的.我还尝试创建该 javascripts文件夹,但仍然无法加载它.当我将夹具片段放置在SpecRunner.html主体中时,它可以工作.

Problem is that jasmine-jquery in not loading my fixtures from spec/fixtures folder. Now when I look at jasmine-jquery source code default path for fixtures is spec/javascripts/fixtures. In a version that I have, there is no spec/javascripts/fixtures folder. It seems it is something for Ruby gem. I also tried to create that javascripts folder but still it can't load it. When I place my fixture fragment inside of SpecRunner.html body - it works.

这是我的html片段:

Here is my html fragment:

<ul class="fr">
    <li></li>
</ul>

规范文件:

describe("something to describe", function() {

    it("should see a DOM element", function() {
        loadFixtures("custom.html");
        expect($(".fr")).toExist();
    });
});

是错误还是带有路径的东西?

Is that a bug or something with the path ?

已解决: google-chrome有问题.默认情况下,它不允许通过相同的来源策略访问其他域.解决方案是从本地服务器运行应用程序,或使用firefox.

Solved: It is a problem with google-chrome. By default it doesn't allow access to other domain by same origin policy. Solution is to run app from local server, or to use firefox.

推荐答案

确实与Chrome有关.这是一个称为相同来源策略的安全概念.

It indeed has to do with Chrome. This is a security concept called Same-Origin Policy.

您仍然可以在禁用该安全检查的情况下使用Chrome,而不是从本地服务器运行Firefox或该应用.

Instead of running Firefox or the app from local server, you can still use Chrome with that security check disabled.

只需使用命令行参数--allow-file-access-from-files运行Chrome/Chromium:

Just run Chrome/Chromium with the command-line argument --allow-file-access-from-files:

google-chrome --allow-file-access-from-files

记住!!由于这是一项安全功能,因此禁用此功能将使您的计算机处于危险之中.建议仅在测试本地网站/应用程序时使用此参数(通过其他快捷方式/别名).

Remember! Since this is a security feature, by disabling it you are putting your computer at risk. It is recommended to only use this parameter when testing local websites/apps (via a different shortcut/alias).

这篇关于茉莉花jQuery夹具不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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