Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing imports from generated spec files #12778

Closed
mina-skunk opened this issue Aug 21, 2018 · 4 comments · Fixed by #12842
Closed

missing imports from generated spec files #12778

mina-skunk opened this issue Aug 21, 2018 · 4 comments · Fixed by #12842
Assignees
Labels
good first issue This issue is a good place to start for first time contributors to the project P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@mina-skunk
Copy link
Contributor

mina-skunk commented Aug 21, 2018

Bug, feature request, or proposal:

spec files from schematics fail

What is the expected behavior?

ng test to work out of the box after only ng generate commands

What is the current behavior?

ng test has template errors

What are the steps to reproduce?

ng new errors-schema
cd .\errors-schema\
ng add @angular/material
ng generate @angular/material:material-dashboard --name my-dashboard
ng generate @angular/material:material-nav --name my-nav
ng generate @angular/material:material-table --name my-table
ng test

for my-dashboard I had to add:
imports: [ MatGridListModule, MatMenuModule, MatIconModule, MatCardModule ],

for my-nav I had to add:
imports: [ NoopAnimationsModule, MatSidenavModule, MatToolbarModule, MatListModule, MatIconModule ],

for my-table I had to add:
imports: [ NoopAnimationsModule, MatTableModule, MatPaginatorModule, MatSortModule ],

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular CLI: 6.1.4
Node: 8.11.1
OS: win32 x64
Angular: 6.1.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.4
@angular-devkit/build-angular     0.7.4
@angular-devkit/build-optimizer   0.7.4
@angular-devkit/build-webpack     0.7.4
@angular-devkit/core              0.7.4
@angular-devkit/schematics        0.7.4
@angular/cdk                      6.4.6
@angular/cli                      6.1.4
@angular/material                 6.4.6
@ngtools/webpack                  6.1.4
@schematics/angular               0.7.4
@schematics/update                0.7.4
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.9.2

I can simply make pull request adding the imports to https://github.com/angular/material2/blob/master/src/lib/schematics/dashboard/files/__path__/__name%40dasherize%40if-flat__/__name%40dasherize__.component.spec.ts if desirable.

@devversion
Copy link
Member

Please do. I'd happy to review your Pull Request!

@devversion devversion added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent good first issue This issue is a good place to start for first time contributors to the project labels Aug 21, 2018
@devversion devversion self-assigned this Aug 21, 2018
devversion added a commit to devversion/material2 that referenced this issue Aug 26, 2018
If someone generates components with Angular Material by using our schematics and runs `ng test` afterwards, the tests will fail because:

* The needed Material modules are not being imported
* No animation module is specified (either `Noop` or `BrowserAnimationsModule`)
* `fakeAsync` is used to run `compileComponents`. `async()` should be used to wait for `compileComponents` (see the default CLI component schematic)

Fixes angular#12778
@devversion
Copy link
Member

devversion commented Aug 26, 2018

Hey @gatimus, just want to let you know that I've submitted a PR to fix the issue.

Since we need to have the schematics working as soon as possible, I've went ahead and created the change myself. I hope you didn't start working on a pull request. Thanks for the issue though!

jelbourn pushed a commit that referenced this issue Aug 26, 2018
If someone generates components with Angular Material by using our schematics and runs `ng test` afterwards, the tests will fail because:

* The needed Material modules are not being imported
* No animation module is specified (either `Noop` or `BrowserAnimationsModule`)
* `fakeAsync` is used to run `compileComponents`. `async()` should be used to wait for `compileComponents` (see the default CLI component schematic)

Fixes #12778
@mina-skunk
Copy link
Contributor Author

@devversion thank you, sorry, I got wrapped up in something else before I saw your comment.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue This issue is a good place to start for first time contributors to the project P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants