Adding a Unit Test to Filer

Mera Gangapersaud
MeraG
Published in
2 min readSep 28, 2018

After familiarizing myself with the NodeJS File System Module I moved on to Filer, an open source project to interface NodeJS and browser-based JavaScript. This was my first foray into contributing to an Open Source project so I decided a simple test would be good to start with.

I tackled a simple task of adding a unit test to Filer for the fs.open function. I noticed while going through the unit tests for fs.open that a case of an invalid flag is not checked. So I opened the issue. The community is helpful and eager to teach any willing participants. To be honest I think I could have found a more difficult issue to handle and succeeded just as well as I did here.

Nonetheless, fixing this issue was still a learning curve for me. I have never used chai or mocha and I find it to be an extremely simplistic and effective way to create a unit test. At first, I tried to construct my test using a similar format as the pre-existing tests which didn’t work. My solution failed the Travis CI test. The comments on my pull request aided me to fix the commit I made. After some more debugging I realized my test had to check for a thrown error due to the way the function was coded; I had to test for my error in a different way. Now my solution successfully passed the Travis CI build.

Going forward I want to challenge myself more and take the initiative to participate in the community more.

--

--