jeudi 28 juillet 2016

Can't find variable: require - Jasmine Unit testing using Chutzpah

I'm really new to Churtzpah and Jasmine. I have been trying to run tests using Chutzpah. I'm using Jasmine, Typescript , Chutzpah , angular2 to write unit tests. Whenever i try to run the tests , I see that my tests are being detected . My chutzpah.json file is as follows :

{
  "Compile": {
    "Mode": "External",
    "Extensions": [ ".ts" ],
    "ExtensionsWithNoOutput": [ ".d.ts" ]
  },
  "References": [
    {
      "Path": "../app/ ",
      "Includes": [ "*.ts" ],
      "Excludes": [ "*.d.ts" ]
    }
  ],
  "Tests": [
    {
      "Includes": [ "*.spec.ts" ],
      "Excludes": [ "*.d.ts" ]
    }
  ]
}

File system in my project

app is the folder where i have all my unit tests and the other typescript files.

    /// <reference path="../../require.d.ts" />
// <reference path="../typings/jasmine/jasmine.d.ts" >

import {it, describe, beforeEach, inject, beforeEachProviders} from "@angular/core/testing";
import {HTTP_PROVIDERS} from "@angular/http";
import {LoginService} from "./login.service";

describe("testing LoginService", () => {
    let Myservice: LoginService = new LoginService();
    it("Should return true", () => {
        expect(Myservice.validateUser("test", "test")).toBe(true);
    });
        it("validateUser should fail if input values are null", () => {
            expect(Myservice.validateUser(null, null)).toBe(false);
        });
    });

Let me know what else I need to do. thanks

Aucun commentaire:

Enregistrer un commentaire