Search code examples
javascriptunit-testingjasminechutzpah

chutzpah not importing referenced file in jasmine test


I have a simple test file "test.js"

/// <reference path="./api.js" />

describe("value is true", function () {
    var api = new Api();

    describe("audio", function () {
        it("returns white space when text is null", function () {
            expect(api.value).toEqual(true);
        });            
    });        
});

and the file that implements the class "api.js" under the same directory

var Api = function () {
    this.value = true;
};

I got the test runner from nuget (version 4.2.4) installed one level up in the directory structure.

I execute the following command

 .\chutzpah.console.exe .\Tests\test.js

The result is "Test 'value is true:encountered a declaration exception' failed ReferenceError: Can't find variable: Api in file:///C:/temp/tools/Tests/ test.js (line 4)"

What's wrong?


Solution

  • I tried to replicate and it worked fine. Are you sure the files are in the same directory. Here is my setup:

    enter image description here

    And the files are exactly what you copied and then I ran the following and it passed:

    enter image description here