Re:Hard-won lessons: Five years with Node.js
by mattmanser on Thursday April 20, 2017 @10:44AM
(#14157077)
In the idealized functional world that doesn't exist, maybe.
Programming anything beyond a small app is ultimately managing complexity and often fixing how the various moving parts don't quite work together as you intended.
You simply can't, and shouldn't, unit test that stuff.
You write a new unit test using the data which caused the bug but expecting a non-error state. The error that is being thrown/rejected will have a stack trace you can inspect to find the line which threw. To find the real cause you need to read the code before this to find out how the bad state was created.
If you kept things small and simple, it is not so difficult to work out what went wrong. If you let things grow in complexity too much, you can however end up within a breakpoint/log quagmire.