Here's what happened 👇#200wordsTIL
I'm building a library that converts markdown into tweets. No UI yet so it makes sense to write tests and run those.
I used nwb so my project came preconfigured with Karma and everything you need for tests.
yarn test:watch 👌
Yesterday this worked great. Messed around with remark and got something working.
Today, I tried to use the AWS Lambda I built 2 months ago for techletter.app to convert code blocks into Carbon screenshots.
Imagine writing a tweet with some code and it magically becomes pretty. Wonderful. 🧙♂️
And that's when all hell broke loose.
node, you see, doesn't have fetch. It doesn't have btoa either and I needed that too.
Tried node-fetch. Didn't work in my webpack'd environment. Tried node-isomorphic-fetch. That worked.
Now I'm importing a huge polyfill for something I won't even need just so I can run tests. That's silly.
Even had to fake the btoa() function. Just for tests. Waste of code.
And the coup de grace?
Karma kills my async function before it has the chance to finish. Tests pass, sure, but without checking the result.