Jasmine test fails running in VS2012 + Resharper + PhantomJS

心已入冬 提交于 2019-12-02 02:43:19

问题


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

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

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

UPDATE

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" />

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

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


回答1:


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. Run the tests in a standard browser (Chrome) instead of PhantomJS, you can set it up in:

Resharper -> Options -> Tools -> Unit Testing -> JavaScript Tests -> Run Tests with...

  1. Add this line of code before your test:

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

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.



来源:https://stackoverflow.com/questions/25621148/jasmine-test-fails-running-in-vs2012-resharper-phantomjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!