Jasmine 测试在 VS2012 + Resharper + PhantomJS 中运行失败 [英] Jasmine test fails running in VS2012 + Resharper + PhantomJS
问题描述
我尝试在 vs2012 的 resharper 7 中运行 jasmine 单元测试,但失败了.
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 或已知 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
推荐答案
不,你不能更改 url.但是导致您的测试失败的原因很可能是缺少文件引用.您可以做的是调试测试并检查加载的文件引用并查看缺少的内容:
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:
- 在标准浏览器 (Chrome) 而不是 PhantomJS 中运行测试,您可以在以下位置进行设置:
Resharper ->选项->工具 ->单元测试->JavaScript 测试 ->使用...运行测试
- 在您的测试之前添加这行代码:
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.
这篇关于Jasmine 测试在 VS2012 + Resharper + PhantomJS 中运行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!