在VS2012 + Resharper + PhantomJS中运行Jasmine测试失败 [英] Jasmine test fails running in VS2012 + Resharper + PhantomJS

查看:179
本文介绍了在VS2012 + Resharper + PhantomJS中运行Jasmine测试失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在vs2012中的resharper 7中运行茉莉花单元测试,但是它失败了。

I tried to run a jasmine unit test in resharper 7 in vs2012 but its failing.

resharper + phantomjs在自动生成的url中运行它可能是导致失败的原因

resharper + phantomjs is running it in autogenerated url which maybe the cause of the failure

有没有办法配置测试使用绝对或已知的URL?

is there a way to configure the test to use an absolute or a known URL?

更新

我在我的* spec.js文件中添加了js引用

I added js reference in my *spec.js file

/// <reference path="../jasmine/jasmine-html.js" />
/// <reference path="../jasmine/jasmine.js" />
/// <reference path="../jasmine/boot.js" />
/// <reference path="../jasmine/console.js" />
/// <reference path="Player.js" />
/// <reference path="Song.js" />
/// <reference path="SpecHelper.js" />

它修正了参考错误,但是当我在resharper中运行它时它仍然无法通过。现在我在尝试调试时出现此错误

and it fixed the reference error, but when i run it in resharper it still wont pass. now i have this error when i try to debug

我也尝试在chutzpah运行测试,它能够执行并传递测试
所以我不确定是什么resharper有问题

I also try running the test in chutzpah and it was to able to execute and pass the test so i'm not sure what is wrong with resharper

推荐答案

不,你不能改变网址。
但是导致测试失败的原因很可能是缺少文件引用。你可以做的是调试测试并检查加载的文件引用并查看缺少的内容:

No, you can't change the url. But what is causing your test to fail is most likely a missing file reference. What you can do is to debug the test and check the loaded file references and see what is missing:


  1. 在标准浏览器中运行测试(Chrome)代替PhantomJS,
    你可以设置它:

Resharper - > ;选项 - >工具 - >单元测试 - > JavaScript测试 - >使用...运行测试


  1. 在测试前添加以下代码:

jasmine.getEnv()。currentRunner()。finishCallback = function(){};

这将覆盖 finishCallback 函数,该函数被调用以通知Resharper测试完成,因此测试将永远运行您可以通过按F5并无限期调试来刷新它。您只需手动停止测试,然后在Resharper的单元测试会话窗口中。

This will override the finishCallback function which is called to notify Resharper about test being finished, so the test wil run forever and you can refresh it by hitting F5 and debug indefinitely. You only must stop the test manually then in Resharper's Unit Test Sessions window.

这篇关于在VS2012 + Resharper + PhantomJS中运行Jasmine测试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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