angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

"ng test" returns errors even after adding "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas'

Open darrenbrett opened this issue 9 years ago • 6 comments

Development Environment: @angular/cli: 1.0.0-beta.30 node: 7.4.0 Chrome 56.0.2924 (Mac OS X 10.11.6)

After creating a few tests, when I run "ng test" I get errors like this one:

  1. If 'app-search-field' is an Angular component, then verify that it is part of this module.
  2. If 'app-search-field' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" [ERROR ->]
    "): AppComponent@6:8

My understanding is that this has to do with the naming of selector tags.

So, following the instructions in the error above, as well as what I found online, I added "CUSTOM_ELEMENTS_SCHEMA" to both my root module, and all other modules. But I am still getting the same errors.

darrenbrett avatar Feb 14 '17 19:02 darrenbrett

What was the problem here? I am stuck on this.

KTKate avatar Mar 15 '17 17:03 KTKate

For any who find this trying to solve this problem like I did: you have to import and add the component you generated to the app.component.spec.ts (or I guess whatever the appropriate spec.ts file is for your situation).

KTKate avatar Mar 15 '17 23:03 KTKate

@JKGisMe can you elaborate on that please?

ERPedersen avatar May 12 '17 01:05 ERPedersen

@ERPedersen For me worked adding generated component to declartaions array like this:

beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ LinkingToolComponent, GeneratedComponent ], imports: [MaterialModule, NoopAnimationsModule] }) .compileComponents(); }));

oskarski avatar Jul 14 '17 13:07 oskarski

@ERPedersen, thanks bro !!!!!!!!

tonymedrano avatar Jan 10 '18 12:01 tonymedrano

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.