Important Angular notes
If you are testing any of these @Input thingies, like these:
Just know that even the most simple of Angular component tests will require these to be defined, IFF they're used in the HTML file like so:
Without defining a value for filters in the beforeEach method, the unit test will fail. But if you define it as follows, it will pass (see the component.filters assignment):
So this is why your unit test might be failing despite being completely empty or only having a simple expect toBeTruthy in there.
This is the error I was originally getting. TypeError: Cannot read properties of undefined (reading 'usage') at Object.eval [as updateDirectives] (ng:///DynamicTestModule/PhoneFilterComponent.ngfactory.js:56:34)
Here is a picture of it:
And here is a picture of my success after fixing it:
Comments
Post a Comment