So there I am, happily writing unit tests, and suddenly this appears
I keep seeing this error while trying to write Angular tests. I… *think* this happens when something goes wrong during the constructor of a component. I’ve written before about how it could be due to an @Input property not being initialized properly.
But, here I am again… with this unhelpful error… and my component has no @Input.
When in doubt, add moar console logging
I’m not sure why I never thought to do this before, but putting everything in a try/catch and logging the error actually helps a great deal.
Now I get something useful in the console window:
LOG: ‘Something bad happened during initialization TypeError: Cannot read property ‘length’ of undefined’
So then I am able to go find out that I had an uninitialized array… I love javascript…..