compileComponents () is asynchronous. So, we must use async () method like this:
BeforeEach (async (() => {
TestBed.configureTestingModule ({
Declarations: [BannerComponent], // declare the test component
})
.compileComponents (); // compile template and css
}));
not
BeforeEach (() => {
TestBed.configureTestingModule ({
Declarations: [BannerComponent], // declare the test component
})
TestBed.compileComponents (); // compile template and css
});
So, this file must be fixed.
While it's semantically true, I think we can get rid off compileComponents() entirely since webpack inlines all templates etc. under the hood anyways right?
I m agree. But this pr #4757 has been closed ..
Webpack is an internal implementation detail. The tests shouldn't assume it is being used or that it inlines anything.
@clydin I very much agree. As of right now however, the entire codebase that is generated by angular cli kind of assumes webpack. That's why we don't use module.id in component meta data and also relative paths for asses like template and CSS.
That's why I think, tests can be treated the same way. They are generated by Angular CLI which knows its build process internals.
Just thinking out loud here.
You actually can use module.id, internally it is just unused. And the relative paths and inlining don't necessitate webpack. Either can be achieved with other build tool setups.
Either way and in general, I don't think an existing deficiency should be justification for additional.
This can be closed now that #4775 has been merged (even if I do agree with @PascalPrecht that getting rid of compileComponents() as it's not necessary with the current setup could be a good option).
@cexbrayat , you can re-open #4757 ;)
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._
Most helpful comment
While it's semantically true, I think we can get rid off
compileComponents()entirely since webpack inlines all templates etc. under the hood anyways right?