Testing with Inputs and Outputs
Learn how to test inputs and outputs by verifying the input binding and output binding triggers.
We'll cover the following
We will now learn how to test the public API of a component. So far, we have learned how to test components with simple properties and tackle synchronous and asynchronous dependencies. But there is more to a component than that. As we learned, a component has a public API consisting of inputs and outputs that should be tested as well.
Since we want to test the public API of a component, it makes sense to test how it interacts when hosted from another component. Testing such a component can be done in two ways:
We can verify that our input binding is correctly set.
We can verify that our output binding triggers correctly and that what it emits is received.
Verifying input and output bindings
Suppose that we have the following bindings.component.ts
file with an input and output binding:
Get hands-on with 1200+ tech skills courses.