私はChurtzpahとJasmineには本当に新しいです。私はChutzpahを使ってテストを実行しようとしています。私はユニットテストを書くためにJasmine、Typescript、Chutzpah、angular2を使用しています。 テストを実行しようとするたびに、テストが検出されていることがわかります。 次のように私のchutzpah.jsonファイルは次のとおりです。変数が見つからない:require - Jasmine 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);
});
});
は私が私がする必要がある他に何を知ってみましょう。 おかげ
がcompile.batが
@echo off tsc.cmd app/login/login.service.ts app/tests/login.service.spec.ts --sourcemap--declaration
のように見える私はあるかもしれないAngualr-活字体のサンプルがある大胆レポで
Error: 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 ==========
ちょっと@Matthew、あなたの応答のためにありがとう。私は私のchutzpah.jsonに変更を加えました..上の編集chutpah.jsonファイルを見てください。私はまだ変更が必要かどうかを知っています –