Upgraded from Node 8 to Node 12

06/27/2020

So, we recently upgraded our API to Node 12 from Node 8, breaking changes are well... expected, actually more than expected they are a given.

After quite a bit of work the engineer that spear headed the upgrade finished. He created his PR, updated the docker to use Node 12, and updated the CI to use Node 12. It was all working great, except ONE test failed... He had to pivot into other stuff, so it was left there, as a PR just waiting for someone with time to debug it.

We picked it up again, since we would need this upgrade in the short future, and after a couple hours debugging, we found the following:

// Node 8.11
const testFunction = function () {};
testFunction.toString(); // prints out 'function (){}'

// Node 12.16
const testFunction = function () {};
testFunction.toString(); // prints out 'function(){}'

This subtle change broke our tests, as he had some regex that checked some return values and their types using its toString method. In case you didn't see the difference (I sure as hell didn't at first), there was a space between function and the parenthesis ()