You also seem optimistic, unit test don't catch new bugs, they just test for typos and the bugs you already knew about.
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.
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.
Btw the tooling in the Node ecosystem is actually pretty good.