8

I'd really like to be using the R#r test running for my javascript unittests. R#r 7 EAP recognizes the tests but when I launch them the runner shows '... Test wasn't run' for all tests.

I can't find any info on what the R#r test runner expects in terms of configuration/directory structure.

Directory structure and sample test posted here

2 Answers 2

10

A basic/hardcoded jasmin unit test does work under R#r 7 EAP. This implies that jasmine is baked in to R#r i guess. Have an open question regarding same.

describe('resharper jasmine testrunner', function () {
    describe('simplest possible test', function () {
        it('should execute', function() {
            expect(true).toBe(true);
        });
    });
});

Got a pointer on the R#r forum that doc comment references are your 'includes' (or jsTestDriver.conf equiv).

/// <reference path="../../libs/testing/jasmine/jasmine.js"/>
/// <reference path="../../libs/crunch/jquery-1.6.2.js"/>

Have yet to get my real tests passing though the now run. Investigating fixture paths next.

1

I'm not sure how advanced of a solution/structure you're looking for, as I just started looking into this myself, but i have a simple example test "working"*... (using Resharper 7 EAP 7.0.56.103). As far as i know, you can structure your test files anyway/where you want, as long as you include references to all of its dependencies with <reference path="foo/path/file.js" />)

*These pass inside the ReSharper unit tests session window. The browser does not show me any sort of test info but rather a blank screen with some jasmine-related html in the source.

/scripts/cheese.js

function Cheese() {
    return {
        isGood: true
    };
}

/tests/cheeseTest.js

/// <reference path="/scripts/cheese.js"/>
describe('simplest possible test', function() {
    var cheese = null;
    it('cheese is good', function() {
        cheese = new Cheese();
        expect(cheese.isGood).toBe(true);
    });
});

6
  • My attempts at using reference path caused tests to fail. Yours is root relative. I'll give that a try and report back. Addtl info in my R#r forum post. Any chance you are able to debug your javascript under the test runner?
    – John Dhom
    Jun 5, 2012 at 15:04
  • 1
    For me, the debug option in the test runner is disabled.
    – brianc
    Jun 5, 2012 at 15:48
  • 1
    True... using other runners you simply set a breakpoint using the browser debugger. The R#r runner is launching a new browser instance per run making this technique invalid.
    – John Dhom
    Jun 19, 2012 at 17:58
  • This example works for me, but when the test fails (e.g. asserting toBe(false)) the resharper runner is showing me an output of "undefined" "Exception doesn't have a stacktrace". Do you get a better error?
    – mikebridge
    Aug 3, 2012 at 20:00
  • @mikebridge I've solved exactly same issue. Fortunately it's already fixed in the Re# 7.1. See stackoverflow.com/questions/11245016/…
    – zbynour
    Nov 1, 2012 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.