-
Notifications
You must be signed in to change notification settings - Fork 3.1k
karma fails for Tour of Heroes tutorial, part 3, Multiple Components #192
Comments
Found a solution! Figuring perhaps the spec test needs to know about HeroDetailComponent, I modified app/app.component.spec.ts, by adding:
and changing beforeEach() to include HeroDetailComponent in its declarations:
Please update the tutorial to include these changes. |
Found another solution, that I like better: Instead of the changing app/app.component.spec.ts as above, modify app/app.component.ts: add this import at the top:
then add this directives field to the @component decorator:
|
Please update the tutorial with whichever change is preferable. |
We had similar issues with angular2-material@2.0.0-alpha.8-2 components. Your first solution works well, but is there an equivalent workaround to your "directives" include? Thanks for the hint, we were looking for a solution for quite some time now only to get the karma/jasmine tests running again 🍹 |
The right solution is to configure your testing module correctly:
Tour of Heroes doesn't talk about unit tests so it really doesn't make sense to update it with these solutions. Instead, we have the testing chapter at https://angular.io/docs/ts/latest/guide/testing.html |
Thanks for clarifying! :) |
... In app.module.ts |
The tutorial is missing the import in the app.module.ts ; the changes should be added to the tutorial and the final code review section else this doesn't work. The zip file download of the final code of tutorial 5 actually contains the changes but it isn't mentioned in the tutorial itself or the final code review tabs |
For anyone else that stumbles on to this. I ultimately figured this out by getting rid of the '[hero]="selectedHero"' from heroes.component.html and when it auto refreshed I got the auto generated 'hero-detail works'. I am using:
|
It's invalid to have this as a closed issue because it was not |
Agree with farnsworth2008 - shouldn't be closed. I ran through the tutorial and it runs fine, but The tutorial doesn't need to cover this, but since it leaves you with a project that fails most of its tests out of the box, an optional section on the right way to get the heroes project testable would be excellent. The Testing section of the Angular guide starts from the position that your project will be automagically ready to test and [in the beginning] passing its tests. Edit: Regarding other commenters mentioning |
I did not change a thing. But tried the suggestion by @leb9049 to restart the 'ng serve' |
Continued from: #184
I cannot run npm test on the results of the Tour of Heroes tutorial, part 3, Multiple Components.
It produces this error:
It seems to me that hero is a known property of my-hero-detail:
What am I missing?
The text was updated successfully, but these errors were encountered: