Days 3+4 — Adding CI, test coverage and linting
While planning ahead for our final project, the entire team was very clear that we needed a number of tools to support our development process that would ensure we were writing clean, bug-free code that was thoroughly tested and easy to change.
Over the past couple of days, I’ve been working with other members of the team to get these installed.
Travis CI
Although some members of the team had worked with Travis CI before, this was my first experience and it was a great learning experience.
CI stands for ‘continuous integration’ — a technique in development which means to automatically test your code when it is pushed to the master branch and, if it passes, deploy it straight away.
We used Travis for this and I was impressed with how easy the setup was. It’s a bit fiddly to get the linting perfect, and the tests can respond differently on Travis to your local machine but getting the process up and running was extremely satisfying.
Mocha
It feels like there are more testing frameworks for NodeJS than there are stars in the Sky. After exploring our options we settled on Mocha as it has a really neat additional framework called ‘alexa-skill-test-framework’ which (as the name implies!) makes it much easier to test Alexa Skills are working as intended.
Istanbul
Once we had Mocha and the alexa-skill-test-framework up and running it was a relatively simple job to add Istanbul to check test coverage.
This was extremely important to us as we wanted to make sure that our tests were checking each aspect of the quiz app, including both correct and incorrect answers.
I hadn’t used Istanbul before but I would highly recommend it. It was extremely simple to install and presents the results in a clear, concise manner when you run Mocha.
ESLint
ESLint has been a fantastic addition to our project folders. No one on our team had worked with Node before so we are unfamiliar with the expected quality standards for code and how it should be laid out for readability.
We now run ESLint before every Git Push to ensure the code meets language standards and it’s automatically run by Travis during every merge request to confirm the code is of a standard to be pushed into production
Next Steps
From here, we need to get our app deployed onto AWS which will require some amendments to Travis. For now, we can be confident our tools are helping us to maintain good test coverage and clean, bug-free code!