June 03, 2019
I spent most of the day today at work dealing with a weird problem. The summary is that when add prettier as a dependency in a create react app based front end project jest breaks down and none of our tests work. The reason as far as I can tell is that something weird happens to the dependency graph and some babel runtime stuff aren’t where it should be.
When stuff like this happens, and I have no idea what’s going on, I try to locate what I think is the reason for it. Like in this situation I thought it was some dependency doing something weird.
The process from there was to remove everything except react-scripts from dev and regular dependencies. And start the process: run tests, add the dependency it complained about, and repeat until I either got it running or I met the issue.
To my surprice I managed to get it running before getting there. Then I added linting to the mix. Run tests, run lint, add missing dependency.
Then when I discover the problem child I start a new blank project and tries to reproduce it there.
The reason I do the last thing is to make sure it isn’t anything dumb I have done.
My experience is that it is usually because of something I have done, and not a real bug.
The idea behind finding problems is to figuring out where it is, that means where it is not. The most efficient way is to just start in one end and just start looking.
It can be really time consuming. Or is really time consuming. And there are no short cuts to finding the kind of problems that don’t give you any hints.
You just need to think straight, pick a strategy and start in one end.