Does anyone have an example of unit testing a component inside a module in angular 2.0?

I am having trouble understanding the correct way to test my components that are inside the module. If ComponentA belongs to ModuleA, what is the correct way to configure testModule?

 TestBed.configureTestingModule({imports:[ModuleA]})

gives me errors like Unexpected value of 'undefined' declared by ModuleA. I guess I get into some bad circular addictions by doing this.

  TestBed.configureTestingModule({declarations: [ComponentA]})

gives me errors like Type ComponentA, is part of the declarations of two modules: DynamicTestModule and ModuleA!

Is one of these strategies right or is there a third way that I'm missing here?

+4
source share

Source: https://habr.com/ru/post/1655388/


All Articles