/// <reference path="..." /> problems with coffeescript

I write my jasmine specs in coffeescript and want to run them using Resharper test runner.
Since there is no support for CoffeeScript, I use Web Workbench to monitor and compile them to javascript continiously. Then Resharper is able to run the pecs. The problem is that because coffescript creates a wrapper function, the reference to my script that I want to test, is not placed on top of the file. Apparently, the testrunner requires it to be on the top, so I have to modify the compiled file to make the dependencies work.

mySpec.coffee:

`/// <reference path="../Scripts/MyFileToTest.js" />

`

describe "when testing the environment", ->

  it "should execute a simple javascript expression", ->

    expect(1==1).toBe true


  it "should load the dependency", ->

    expect( aTruthyValue ).toBe true


compiles to myspec.js

(function() {

  /// <reference path="../Scripts/MyFileToTest.js" />

;

  describe("when testing the environment", function() {

    it("should execute a simple javascript expression", function() {

      return expect(1 === 1).toBe(true);

    });

    return it("should load the dependency", function() {

      return expect(aTruthyValue).toBe(true);

    });

  });


}).call(this);

Result: 1 of 2 test pass with Resharper test runner


has to be modified to the following to get it work:
(function() {
  /// <reference path="../Scripts/MyFileToTest.js" />
;
  describe("when testing the environment", function() {
    it("should execute a simple javascript expression", function() {
      return expect(1 === 1).toBe(true);
    });
    return it("should load the dependency", function() {
      return expect(aTruthyValue).toBe(true);
    });
  });


}).call(this);

Result: 2 of 2 test pass with Resharper test runner


Any ideas?

3 comments
Comment actions Permalink

Hello Edgar,

I don't see a difference between original and modified js code you provided. Could you please specify the code sample correctly?

Thanks in advance.

0
Comment actions Permalink

Oh sorry.This is the modified js file:

  /// <reference path="../Scripts/MyFileToTest.js" />
;
(function() {
  describe("when testing the environment", function() {
    it("should execute a simple javascript expression", function() {
      return expect(1 === 1).toBe(true);
    });
    return it("should load the dependency", function() {
      return expect(aTruthyValue).toBe(true);
    });
  });


}).call(this);
0
Comment actions Permalink

Edgar,

Thanks - I beleieve this is a by-design behavior for JS Unit Tests - references should be placed on top of the file. I would recommend to report about this bug to the Web Workbench team so they could implement this type on conversions correctly.

0

Please sign in to leave a comment.