Review of my week [#2 - 21/03/08 - 21/03/14 ]
Just a weekly sharing of my story.
9 min read
Last week I reviewed my goals. This week I tried to take actions towards those goals and I'll share those achievements with you in this post.
Done this week
Here is a summary of the things I've done :
- Tests with Mocha / Chai and Sinon for the API
- Open Source Contributions
- Tough time with Zettelkasten
- My Knowledge available online
- A new tool to help frontend development
So let's get into the details.
Tests with Mocha / Chai and Sinon
This week, I worked a lot on testing. I've never had to use testing before and I needed to get into it because it seems to be an important step in software development. And after a week of doing it, yes it is.
I started with unit testing which consists of testing a small atomic part of your app like a function. The goal is to test every case possible to prevent errors that we would have missed testing the app only by running it.
Here is an example of a function I've tested. The function takes only one argument, the user id and should return a Promise object or should return false if the user id is not provided.
So the cases that needed to be tested here is, first when no argument is provided we expect the function to return false. What is funny is that actually, we use Mocha and Chai to make test writing almost using plain English. Here is the code I've created to test the first case.
As you can see mocha provide a method to write tests, here, I used the method named
it. The first argument is the message we will see in the console. The second argument is the test function. Chai is a library that allows us to write test using almost plain English as I said which is
expect. We give the expect function what we want to test, here the method
getUserById(). Remember we want to test the behaviour if we don't provide this function with an argument so we need to call it with no argument. Then we call the method because we want to test what this function returns. And lastly, we expect it to be false.
I tried to implement test throughout the API I'm building and I still have a lot to learn but trying to implement tests make me learn some things and face some error that makes me think differently. One error I faced was a function that uses an instance object from mongoose. I'll write a dedicated post about it.
Open source contributions
Tough time with zettelkasten
I learned about Zettelkasten about 2-3 months now with the book written by Sönke Arhens, How to takes smart notes. Since then, I watched a lot of videos and tried to implement it using Roam Research, Notion and Obsidian. But I realized that what was wrong was how I was taking those notes and how I was processing them. I tend to take lots of notes and I don't clarify what those notes mean often enough.
My knowledge available online
A new tool for frontend development
As I said, I've started to contribute to an open-source project on Github and doing so, I discovered a tool that I didn't know existed before. It is storybook. Storybook allows you to work on a small component with React ( you can use it with Vue and Angular as well ), without actually running your server. It launches a preview of your component so you can work on it before using it in your project. I think this is a great tool because it allows you to write your component, test it without running your app and heading to the part where you're using that component. I'm still new to it and didn't use the full power of it but, still, I enjoyed creating and animating the component such as the button I'll use over my app or the input.
That was it for this week's review, I didn't write that much this week for my blog and Instagram account as I was too focused on the code, so one of the goal for the week that is to come is to write more content, so I can share more of what I learn and level up my English as well. I hope you enjoyed this post, feel free to give any constructive feedback.
Thanks to V2osk for the free cover picture.