Jasmine test fails running in VS2012 + Resharper +

2019-02-26 20:41发布

问题:

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.