When testing a component that has sub-components you have a few options:
NO_ERRORS_SCHEMA
and ignore sub-components.Given that most of the time you only care about the current component, why isn't NO_ERRORS_SCHEMA
given more attention in the testing tutorials, blog posts, etc.?
I know it's flagged as experimental but I'm not bothered by that since
So are there problems with NO_ERRORS_SCHEMA
? Or is it just happenstance it's not promoted more?
I agree with @jonsharpe's assessment in that, you hide any template errors when you use NO_ERROR_SCHEMA, you will likely mask schema errors.
The alternative of importing the module with TestBed
causes dependency-tree-hell.
There is a third alternative shallow-render that will mock your dependency tree automatically so you get type-safety, template safety and dependency-tree resolution with a single line of test setup.
Full-disclosure, I am the author of shallow-render.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With