Open Source Contribution – Filerjs – Release 0.1

Our professor, David Humphrey, introduced one of the open source projects, called filerjs. Filer is a file system interface running on browser, which is similar to Node.js file system modules. Recently, Filer added new features for implementing fsPromises modules, but tests for this were not added; we, OSD600 students, were asked to add the test codes to ensure that newly added fsPromises modules are working well.


Before I started writing the test codes, I had to make sure that Node.js fsPromises modules were working on my laptop. Since Node.js fs Promises APIs were added in Node version 10.0.0 (see this), I upgraded the node version to latest one on my laptop by running nvm :

nvm install 10.10.0 && nvm use 10.10.0

Since I researched and posted about Node.js file system readdir modules in the previous post, I decided to write a test code for Filer fsPromises.readdir module. I wrote some sample code for Node.js fsPromises.readdir module in a Promise way.

Sample code

const fsPromises = require('fs').promises;

    .then(() => {'tmp/file1', 'w');
    .then(() => {
        return fsPromises.readdir('tmp')
    .then(files => {
        console.log("The contents of directory tmp : " + files);
            .then(() => {
                console.log("'file1' is successfully deleted");

        return fsPromises.readdir('tmp');
    .then(files => {
        console.log("The contents of directory tmp : " + files);

            .then(() => {
                console.log("'tmp' directory is successfully deleted");
    .catch((err) => {

Sample Code Output

The contents of directory tmp : file1
'file1' is successfully deleted
The contents of directory tmp : 
'tmp' directory is successfully deleted


First, I had to file an issue about missing fsPromises.readdir module test codes, especially the case when the path exists and is a directory. Before I submit the issue to github, I checked all other issues which were already posted, so that I do not file the same issue again.

Here is my issue link : Issue #426

After that, I forked the filerjs repository, created new branch with the name ‘issue-426’ on the forked repository. Under the test directory, I could find the file called ‘fs.readdir.spec.js’. I did not know how the testing tools, such as ‘chai’ and ‘mocha’, work perfectly, but I could guess while I was looking over the existing code. Because I was not writing the test code from scratch, I simply copied and modified the existing code for testing fsPromises.readdir module.

fsPromises.readdir() test code when the path exists and is a directory

describe('fs.readdir', function() {


  it('(promise) should be a function', function() {
    var fsPromises = util.fs().promises;
  it('(promise) should return a list of files from an existing directory', function() {
    var fsPromises = util.fs().promises;

    return fsPromises.mkdir('/tmp')
      .then(() => {
        return fsPromises.stat('/');
      .then(stats => {
      .then(() => {
        return fsPromises.readdir('/');
      .then(files => {
      .catch(error => {

I checked other people’s Pull Requests and read some comments about coding styles before I did Pull Request. When we modify the existing codes, we should follow what previous person wrote. I realized that my code had different indentation, so I changed the indentation spaces from 4 to 2 so that it matches the original one.

Here is my pull request link : Fix issue-426

After pull request, I had some clarifications which were about the structure of the code. First, I was wondering if I should create the new file called ‘fsPromises.readdir.spec.js’, instead of adding new code under ‘fs.readdir.spec.js’ file. In addition, I was a little bit confused whether I create new test group, called ‘fsPromises.readdir’, or write the code under the same group(‘fs.readdir’) with ‘promise’ prefix in front of each test case description. The code our professor provided was adding ‘promise’ on the description, so I followed his styles of coding. I realized that it is not easy to follow other’s preferred coding styles.

Review and Helps

Here is my pull request link :
Add test for fsPromises.symlink() when file soft link dose not exist

I also looked at one of the pull requests about adding test code for fsPromises.symlink module. I read the commits and suggested some code changes. Basically, the writer duplicated the existing code, but fsPromises.readdir module was not applied. He fixed the code based on people’s suggestions. I think it is really important to review other people’s code and get some feedback from others. This helps improving the quality of our code, as well as fixing the bugs and errors. Also, by communicating with other people around the world who are contributing to the same project about other issues or suggestions, you can find the solution to some problems you get stuck.

I did help out other students in person who have some issues with pushing codes to github. The problem was that git was recognizing all the parent directory’s files as an untracked files, as well as the current directory. It could be solved easily by changing current directory to the subdirectory. I did not have many chances to help other people, but it was very meaningful experience for me. I will try to find more opportunities to review and give feedbacks, as well as getting help from other people in the open source project.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website at
Get started
%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close