Problems with Angular NO_ERRORS_SCHEMA?

When testing a component with subcomponents, you have several options:

  • Import a module that installs a component and subcomponents. The problem is that you are creating real subcomponents and their dependencies.
  • Layout subcomponents. This can be tedious depending on how many subcomponents it has.
  • Use NO_ERRORS_SCHEMA and ignore subcomponents.

Given that most of the time you only care about the current component, why is NO_ERRORS_SCHEMA not paid more attention to test tutorials, blog posts, etc.?

I know that this is marked as experimental, but it doesn’t bother me, as

  • it comes with the rest of angular and
  • the entire Angular stack is pretty much experimental, given its history and the upcoming release cycle.

Are there any problems with NO_ERRORS_SCHEMA ? Or is it just an accident, it did not contribute to the increase?

+10
source share
1 answer

I agree with @jonsharpe's assessment that you hide any pattern errors when using NO_ERROR_SCHEMA, you will probably mask schema errors.

The alternative to importing a module with TestBed causes a dependency-tree-hell.

There is a third alternative to shallow-render , which will mock your dependency tree automatically so that you get type safety, template security, and dependency β€” tree resolution with one line of the test setup.

Full disclosure, I am the author of the shallow-rendering.

+3
source

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


All Articles