dimanche 31 juillet 2016

Jasmine can't find namespace (internal module)

I'm trying to use jasmine to test functions of a typescript class.

My spec is test.ts (my gulp test task feeds the js to jasmine).

/// <reference path="../lib/bar.ts" />

import Bars = com.bar;

describe("Bartender test", function () {
    describe("See if I get served a drink", function () {
        var myBartender: Bars.Bartender = new Bars.Bartender();
        it("should serve a drink", function () {
            expect(myBartender.getBeer()).toEqual(<Bars.IDrink>{});
        });
    });
});

Bar uses namespace com.bar and looks like this:

namespace com.bar {
    export interface IDrink {
        volume: number;
    }

    export class Bartender {

        constructor() {

        }

        public getBeer(): IDrink {
            return <IDrink>{ volume: 1 };
        }
    }
}

When I run this test I get ReferenceError: com is not defined. Intellisense Visual Studio says all is fine.

My gulp task for test:

return  gulp.src('./src/spec/test.js').pipe(jasmine());

Does Jasmine need a list of js files even though they are referenced in the test?

Aucun commentaire:

Enregistrer un commentaire