Adding Jest to Telescope

Continuing from my last blog, I did not actually create a pull request so today I will be looking through issues to work and contribute to telescope.

Finding an Issue

I look through so existing issues instead of creating my own, and I found an issue about adding a testing infrastructure to telescope. I have some interest in testing so I decide to take on this issue.


I wanted to do some research about test infrastructures before tackling the issue. The issue provided information about some test infrastructures that could be used, Jest and Mocha. Reading this blog gave some insight on the pros and cons of both testing infrastructure Jest vs Mocha whats the difference. I decide to use Jest here is more reasoning:

  • Jest setup was easier to setup.
  • Jest sent a warning message about problems with async operations while Mocha did not.

Mocha does seem to be more flexible, but the setup takes some time. Maybe in later development there can be a switch, but for a starting point ill be using Jest .

I posted my findings on the issue and start to create a simple test to see if Jest is working. Here is my simple test:

test('Testing feed-queue.js', () => {

My test did not do much other than check if the Redis server was running, once the feed-parser is merge in student will be able to create new tests that can hopefully replace this one. Once I created my simple test, it was time to run it. I had to change the package.json file to call on my test (test: "jest"). Running the command npm test produces these results at the end of the test:

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

It took me a VERY long time to find out what the problem was. I initially thought that it was a problem about asynchronous functions. Jest had great amount of documentation about asynchronous functions, but sadly this was not the reason why my test not exiting correctly. I was able to finally found out the problem on the stackoverflow site. Apparently if the Redis server is online this error occurs, to solve this you must close the Redis server when finish testing which is not ideal. Hopefully this issue can be resolved in future builds.

Creating pull request

Now that I have setup Jest and created a simple test I can now commit and create a pull request. The problem is that my master was behind a commit that was recently merge so I had to rebase my repository.

I had some problems with rebasing but had help from Professor David Humphrey and was able to apply my changes. Note to self, git log is a very helpful command to tell if your commit is above the current upstream master branch.

Now that the test infrastructure is in, students can now create as many tests needed. I am also interested in Jest so I will also be trying my hand in creating more tests in the future hopefully.


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