我正在使用Angular2 Cli構建Angular2應用程序。 我有角產生一個具有這樣Angular 2提供的參數不匹配調用目標的任何簽名(spec.ts)
constructor(private _elRef: ElementRef) {}
構造當我建(NPM開始)我得到這個錯誤
...angular2/tmp/broccoli_type_script_compiler-input_base_path-wKrIZXNv.tmp/0/src/app/notifications/notifications.component.spec.ts (10, 21): Supplied parameters do not match any signature of call target
文件notifications.component.spec.ts一個notifications.component cli是這樣的
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { addProviders, async, inject } from '@angular/core/testing';
import { NotificationsComponent } from './notifications.component';
describe('Component: Notifications',() => {
it('should create an instance',() => {
let component = new NotificationsComponent();
expect(component).toBeTruthy();
});
});
但是,如果我沒有構造參數構建一切工作正常。如果在構建之後添加此參數,則一切正常。
我缺少什麼?
我注意到,但我試圖提供一個參數,但任何不工作!你有什麼建議? –
如果您的'NotificationsComponent'不需要'ElementRef',只需將它從構造函數中移除即可。否則,你可能想要檢查你正在使用哪個測試框架,併爲它提供一個存根。 –
我可以刪除,但我想知道如何解決它! –