2016-07-26 1 views
4

Angular2 App을 Angular2 Cli를 사용하여 빌드하고 있습니다. 나는 (NPM 시작) 나는이 오류를각도 2 제공된 매개 변수가 호출 타겟 (spec.ts)의 서명과 일치하지 않습니다.

...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를 얻을 수를 만들 때이

constructor(private _elRef: ElementRef) {} 

같은 생성자가 각도에 의해 생성 된 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(); 
}); 
}); 

같다. 빌드 후에이 매개 변수를 추가하면 모든 것이 잘 작동합니다.

내가 무엇을 놓치고 있습니까?

답변

1

이 라인을보십시오 let component = new NotificationsComponent();.

NotificationsComponent에 대해 새 개체를 만들 때 인수를 제공하지 않은 반면 생성자는 ElementRef 유형의 개체를 필요로합니다.

그래서 생성자 매개 변수없이 모든 것이 잘 작동합니다.

+0

알아 두었지만 인수를 제공하려했지만 작동하지 않습니다! 당신의 제안은 무엇입니까? –

+0

'NotificationsComponent'가'ElementRef'를 필요로하지 않는다면, 생성자에서 그것을 제거하십시오. 그렇지 않으면 어떤 테스트 프레임 워크가 사용 중인지 확인하고 스텁을 피드 프레임에 제공 할 수 있습니다. –

+0

제거 할 수는 있지만 해결 방법을 알고 싶습니다! –

0

안녕하세요 잘 여기에 같은 문제가 아무도 아직 어떻게 그리고 무슨 일이 일어날 지에 대해 설명 할 수 없지만 당신이 시도 할 수있는 시도에 notification.component.ts 및 변경 생성자 "private _elRef : any = ElementRef) {}" 다시로드 한 다음 다시 변경하십시오.

+0

안녕하세요,이 아이디어를 공유해 주셔서 감사합니다. 그러나 여전히 오류가 발생합니다. zone.js : 463 오류 : 알려지지 않은 (약속 있음) : 오류 : 오류 : NotificationsComponent의 모든 매개 변수를 해결할 수 없습니다 : (?). (...). 당분간 notifications.components.spec.ts에있는 모든 코드에 주석을 달았습니다. –