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

Popular posts from this blog

Unleashing my inner Disney Princess ✩₊˚.⋆☾⋆⁺₊✧ at the 2024 Disney Princesses Half Marathon

The 20-something types of Computer Science majors

The Evenstar