3
npm testコマンドを使用して実行すると、指定された単体テストがエラーをスローします。それはエラーメッセージ "エラー:コンパイラのためのプロバイダがありません!" DI例外があったと言いますエラー:コンパイラのプロバイダがありません! DI例外角2のテスト
エラーがtcb.createAsyncにおそらくスローされimport {TestComponentBuilder} from "@angular/compiler/testing";
import {
expect,
it,
describe,
async,
inject,
beforeEach,
beforeEachProviders
} from "@angular/core/testing";
import {provide} from '@angular/core';
import {TestService} from "../services/Test.service";
import {TestComponent} from "./Test.component";
describe('Component: TestComponent',() => {
let tcb;
beforeEachProviders(() => [
TestComponentBuilder,
TestComponent,
TestService
]);
beforeEach(inject([TestComponentBuilder], (testComponentBuilder) => {
tcb = testComponentBuilder;
}));
it('getTest', testGetTest => {
**tcb.createAsync(TestComponent)**
.then(fixture => {
let TestComponent = fixture.componentInstance;
TestComponent.selectedUserId = 3;
expect(TestComponent.selectedUserId).beEqual(3);
});
});
});
次の依存関係が
"jasmine-core": "~2.4.1",
"karma": "1.x || ^0.13.0",
"karma-chrome-launcher": "1.x || ~0.2.2",
"karma-firefox-launcher": "1.x || ~0.1.7",
"karma-cli": "*",
"karma-jasmine": "1.x || ^0.3.6",
"karma-spec-reporter": "0.0.13",
"browserify": "latest",
"karma-browserify": "latest"