/// <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);
has to be modified to the following to get it work:
/// <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?
Please sign in to leave a comment.
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.
Oh sorry.This is the modified js file:
;
(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);
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.