My learning diary

Reuse Stories When Testing

My volunteering experience at an open source project led me to appreciate Storybook. Developing frontend components in isolation makes me happy. Unexpected behaviour is localised, and you are appropriately enticed to write your components better. By better, I meant modular. Modularity encourages simplicity (think SRP), and this makes code more reusable and self-documenting. There’s no greater joy than not having to explain your code. But wait, there’s more: If you think writing stories is exclusive to your Storybook instance and thus a pain to write, think again.

Continue reading "Reuse Stories When Testing"

Jest for the First Time

I needed to test a feature which I have been building for GovTech’s FormSG. To test it, I had to mock a function in the superclass of an instance generated by a factory method call. I once considered stripping away the barriers between the mock and the test. But, I didn’t want to refactor a codebase which I am not too familiar with. Below is a visualisation of the “barriers” between the mock and the test:

Continue reading "Jest for the First Time"