chutzpah: can't find variable : require - Chutzpah is not recognizing my tests
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" ]
}
]
}`
I had compile.bat before. I removed as i’m not sure of how .bat file should looks like . My test file look like
`/// <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); }); });`
and I see following errors in my console:
Error: ReferenceError: Can’t find variable: require at global code in file:“path”/login.service.spec.js (line 2) While Running:“path”\app\login\login.service.spec.ts ------ Test started: File: “path”\login\login.service.spec.ts ------ 0 passed, 0 failed, 0 total (chutzpah).
Please let me know what I should do and what files I still need
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (4 by maintainers)
I added better support for Angular2 in the 4.3.0 release. Please take a look at the Angular2 sample and see if it helps.
Will close for now but re-open if this doesn’t solve the problem.