Review of my week [#2 - 21/03/08 - 21/03/14 ]

Review of my week [#2 - 21/03/08 - 21/03/14 ]

Just a weekly sharing of my story.

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 :

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.

code.png

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.

code1.png

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

This week I made more contributions to a project on Github, even if those contributions are small, it made me feel like I'm being useful and actually put my knowledge to practice. And with small achievement, self-confidence is built too which is a good and important thing to me. But most importantly, I feel like I want to contribute more, so I'm currently improving my Javascript skills by learning a bit of Typescript so I can do more, as this project uses Typescript. So one advice I could give is to try to contribute to an open-source project even if at the beginning you're creating documentation.

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.

So I just decided to group notes by topic, e.g 'Javascript', 'React', 'testing'... Then I wrote a first permanent note, then added another one and just keep it simple by adding notes and linking them without the worry if I'm writing them good or not, if I have enough information on them. I just write and if I need to make changes on a note, I can link a new one to it explaining the changes and why I decided to make those.

My knowledge available online

There were many people asking me about what I know and what are useful resources about Javascript or other languages. So I decided to create a Github repository where I'll be sharing all my knowledge for the more curious of you and most important than that, all the useful resources I've used and currently use. I've designed a simple roadmap of what I've learned and the things I master the most. So feel free to head on and check this out. Here is the link of the repository

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.

Conclusion

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.