Ich bin wirklich neu in Churtzpah und Jasmine. Ich habe versucht, Tests mit Chutzpah durchzuführen. Ich benutze Jasmin, Typescript, Chutzpah, angular2 um Komponententests zu schreiben. Wenn ich versuche, die Tests auszuführen, sehe ich, dass meine Tests erkannt werden. Meine chutzpah.json Datei ist wie folgt:Variable kann nicht gefunden werden: require - Jasmine Unit testing mit Chutzpah
{
"Framework": "jasmine",
"Compile": {
"Mode": "Executable",
"Executable": "../compile.bat",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ],
"UseSourceMaps": true,
"Paths": [
{
"SourcePath": "../",
"OutputPath": "../"
}
]
},
"References": [
{ "Path": "../node_modules/es6-shim/es6-shim.js" },
{ "Path": "../node_modules/reflect-metadata/Reflect.js" },
{ "Path": "../node_modules/systemjs/dist/system.src.js" },
{ "Path": "../node_modules/zone.js/dist/zone.js" },
{ "Path": "../node_modules/zone.js/dist/jasmine-patch.js" },
{ "Path": "../node_modules/zone.js/dist/async-test.js" },
{ "Path": "../node_modules/zone.js/dist/fake-async-test.js" },
{ "Path": "../node_modules/core-js/client/shim.min.js" },
{
"Path": "app",
"Includes": [ "*.ts" ],
"Excludes": [ "*.d.ts" ]
}
],
"Tests": [
{ "Include": "*.spec.ts" }
]
}
import {it, describe, beforeEach, inject, beforeEachProviders} from "@angular/core/testing";
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);
});
});
Lassen Sie mich wissen, was sonst muss ich tun. dank
die compile.bat sieht aus wie
@echo off tsc.cmd app/login/login.service.ts app/tests/login.service.spec.ts --sourcemap--declaration
ich die folgenden Fehler in dem Testausgabefenster
sieheError: ReferenceError: Can't find variable: require
at global code in file:"path"
0 passed, 0 failed, 0 total (chutzpah).
========== Total Tests: 0 passed, 0 failed, 0 total ==========
Hey @Matthew, danke für Ihre Antwort. Ich habe Änderungen an meinem chutzpah.json vorgenommen .. schaue dir bitte die editierte chutpah.json Datei an. .le mich wissen, ob ich noch Änderungen vornehmen muss –