Seeing the Importance of Testing
Disclaimer: I'm an engineer at Fave, but the content of this post is not related to Fave, it is a side project that I am working on.
Having gone through setting up CI/CD for my small project, I realized that TDD is a pretty cool thing to have and it helps to automate stuff and also gives confidence not just to the coder but also to the reviewer.
The lead up to this blog can be found on the following blogs:
Dreams of automating deployment: Org setup update 1
For every open-source maintainer trying to birth a repo/project for the first time, it is a tough task. For someone as…
A comprehensive guide to setting CI with CircleCI, Jest, Enzyme for React: org setup update 2
As there have been a lot of guides on the internet regarding testing and CI setup, I did run into a lot of issues(part…
I had implemented Jest and Enzyme to set up the tests. Now, as a developer, I am interested in knowing more about testing. The company which I work for, Fave (We are hiring, link at the end of this post), focuses a lot of TDD and I see where and why is it needed.
So obviously I had to go with the most popular option, Jest paired with Enzyme. I still don’t have any idea why did I go with that. But hey, after a damn long setup, which can be found in the above links provided.
GOSH DARN AWESOME! 😱
I was thrilled until I refactored my code right now, and ran into this bad boy.
So apparently Jest can’t deal with importing images.
When you import image files, Jest tries to interpret the binary codes of the images as .js, hence runs into errors.
Did some research, found out that there is something called moduleNameMapper, that needs to be configured for things to work out.
It looks like too much work… NETFLIX BREAK!
*2 episodes later*
Alright! Let’s do this!
As I already had a `jest.config.json` for setting up polyfills for tests and also to set up the Enzyme adapter (I don’t know why, but it wasn’t working otherwise).
All I had to do was add:
Now comes to mocking the files. Created them with a simple
`exports default ‘’;`…
Freakin forgot to add SCSS… Alright, let’s try it again.
The feeling right here is why I choose to be a developer!
Now since everything works out and the branch passes all the unit tests, I can confidently deploy this code knowing it won’t fail in production (most of the time).
You can check out my itsy bitsy open-source org at https://github.com/WrippleFoss/
I am trying to build an open-source platform for something 😉 secret.
You can also join the discord channel using this [link](https://discord.gg/7TahF4D).
Fave is hiring, apply to https://careers.myfave.com/
Until next time…
You can also check out the original blog post at: