So, a little background information…

I have been working on a project for over 10 days called Maintenance Tracker. It’s a web application that allows users to be able to submit and track their maintenance or repair request to an organisation or manufacturer. This article expresses how I faced a seemingly hard challenge while working on integrating code coverage tools, coveralls and code climate and what I learnt during the process.

I’ve been working on the web application for close to 10 days and I have provisioned and started working on the back-end while following some guidelines which stated that I should implement code coverage to know what percentage of my code is tested. According to the guideline, I was to integrate coveralls and code climate which, as most of the other technologies in the guidelines, I haven’t had any form of experience working with.

I had a couple of challenges working on the web application but the biggest of them all, with a seemingly easy solution was making the coverage data get picked by coveralls. It was a very big tussle. Normally I was supposed to install a few packages, as follows:

  • node-coveralls: Sends your test coverage report over to
  • istanbul: instruments your JavaScript code with line counters, so that you can track how well your unit-tests exercise your code base
  • nyc: command line client for istanbul

After installing and setting up the packages, I needed to include the coveralls badge in my file and run the command:

npm run coverage

The command above was declared in my package.json as:

nyc report --reporter=text-lcov | coveralls

It basically takes in your code coverage report in lcov format and sends it to coveralls so that your coveralls badge can be updated with your code coverage. Here in lies the problem.

My code tests was running correctly and I expected the coverage command to run successfully and be transferred to coveralls but it wasn’t and my badge was not getting updated. Coveralls was not receiving any information from my code and I was getting the error:

'error form lcovParse:' 'Failed to parse string'

I decided to hop on to the big G to get some solution and I was able to get some solutions off Github issues and StackOverflow which led to me changing, rewriting and deleting lines out of my ‘.nycrc’ and ‘.babelrc’ files. All these and nothing seemed to be working. I decided to contact a few colleagues I could talk to but even after we decided to uninstall and reconfigure the whole coveralls system, nothing still seemed to be working and I got tired.

After almost 2 days of trying to fix the issue, I decided, after speaking with a colleague, to get my mind off it for a while and went to play some game. I came back to it after a few hours away and decided to go back to checking the Github issues I was reading before and somewhere on a solution, there was a note that says to always run tests with the NODE_ENV=test command. I decided to give it a try, just in case and here it was, a miracle, just like when Moses parted the red sea, my code coverage was reporting and also transmitting to coveralls.

What did I learn from this experience?

I had a few lessons to take away from the whole experience:

  • Don’t stress yourself on an issues: Issues, bugs are a common occurrence and just like someone I know used to say: ‘in programming, bugs are very generous, solve 1, get 2 free’. You should always have it in mind that you’ll hit bugs but how you react to the bugs really helps a lot in been able to solve the bug.
  • Always seek help: Even though my colleagues were not able to solve the issue with me, they were really helpful and most times it would be them who would help solve issues. It was also a colleague that recommended taking some time away from the problem which ultimately led to me been able to solve it, so colleagues do help.
  • Always take a break: Hitting away at the problem wouldn’t solve it. Most times, once you’ve worked a few hours on a problem without a solution, take a break, stretch your legs, play games, disturb a co-worker then come back refreshed and watch the problem get solved.
  • Read a solution in its entirety: Sometimes, at least in my case, this helps. You should not only look at the code solutions, also read the text along with the code, even if it does not hold the key to your happiness as it did in my case, it will help you understand why the code was written the way it was, making it easy for your to edit it to your condition and also it’ll make it easier for you to solve that type of problem by yourself when next you’re faced with it.