I have two components, one of which uses the other.
First: "GamePanelComponent" , which has an html file that contains: "my-game-panel-output" tag
Second:
import { Component, Input } from '@angular/core'; @Component({ moduleId: module.id, selector: 'my-game-panel-output', templateUrl: 'gamepaneloutput.component.html', styleUrls: [ 'gamepaneloutput.component.css' ] }) export class GamePanelOutputComponent { @Input() message: string; }
I wrote a test on GamePanelComponent :
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { DebugElement } from '@angular/core'; import { GamePanelComponent } from './gamepanel.component'; import { GamePanelOutputComponent } from '../gamepaneloutput/gamepaneloutput.component'; describe('GamePanelComponent (inline template)', () => { let comp: GamePanelComponent; let fixture: ComponentFixture<GamePanelComponent>; beforeEach( async ( () => { TestBed.configureTestingModule({ declarations: [ GamePanelComponent ], // declare the test component }).compileComponents() .then(() => { fixture = TestBed.createComponent(GamePanelComponent); comp = fixture.componentInstance; }); })); it('isValidMove', () => { comp.ngOnInit(); let isValid = comp.isValidMove(0,0); expect(isValid).toBe(false); }); });
Unfortunately, the test fails with this error:
Failed: Uncaught (in promise): Error: Template parse errors: Can't bind to 'message' since it isn't a known property of 'my-game-panel-output'.
As you can see, I tried to import the " GamePanelOutputComponent " and this does not help.
I really stuck on it. Can anyone help?
source share