Stack trace for Jasmine test with the Resharper 7 test runner

左心房为你撑大大i 提交于 2019-12-06 03:19:56

Sorry, I don't use Resharper, but I used to face the same issue with phantomjs and jasmine ConsoleReporter.

I think it boils down to the fact that jasmine does not throw an Error message for failed expectations and that the stack is captured by phantomjs only when error is actually thrown (jasmine.js):

jasmine.ExpectationResult = function(params) {
...
var trace = (params.trace || new Error(this.message));
};

Changing that line as follows fixed it for me:

var err;
try { throw new Error(this.message); } catch(e) { err = e };
var trace = (params.trace || err);

In the spec file, where you have your javascript (jasmine) unit tests, you need a reference to the source that is being tested. Normally you have this in the SpecRunner.html, but Resharper rolls it's own SpecRunner.

Add this reference line to the top of the XyzSpec.js file

/// <reference path="/js/path-goes-here/your-file-here.js" />

describe("Utils", function () {
    describe("when calculating quantity", function() {
...

Drove me almost nuts until I started looking around in Resharper's spec runner.

PS: If a new problem shows up 'Unit Test Runner failed to load test assembly' and you have Chrome as default browser, change the browser for javascript unit tests in the Resharper options.

Got a good response from the Jetbrains Resharper team when I logged the issue. They fixed it and it's in the 7.1 release of Resharper, which can be downloaded from their EAP site

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