paint-brush
Running tests for .NET and Node.js on Travis CIby@bartwijnants
633 reads
633 reads

Running tests for .NET and Node.js on Travis CI

by Bart WijnantsJune 11th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Together with a colleague I started working on <a href="http://partei.be" target="_blank">Partei</a>. Like a lot of projects this consists of a web api that does some stuff and a front-end.
featured image - Running tests for .NET and Node.js on Travis CI
Bart Wijnants HackerNoon profile picture

Introduction

Together with a colleague I started working on Partei. Like a lot of projects this consists of a web api that does some stuff and a front-end.

To make things easy we decided to serve our front-end from the same server that serves our api and to keep them in the same git repository. We opted for ASP.NET Core in the back-end and React in the front.

We set up the projects and configured Travis CI to run our tests and publish to Heroku.

Initially we only had .NET tests and Travis ran them without a problem. But then we introduced Jest tests for the front-end. Travis CI has Node.js installed by default on the .NET environment so thing should go smooth.

But things didn’t go smooth. Apparently the default version of Node.js is 4 and our project is written using Node.js 8.

Time to figure out a solution for this.

Solution

I created a repo with a .NET Core test project and an npm project both with a simple test.


bartw/dotnetcore_node_travis_dotnetcore_node_travis - Running tests for dotnet and a specific version of node together in one Travis build_github.com

On Travis CI, Node Version Manager (nvm) is available. In my .travis.yml file I used nvm to install Node.js 8 and use this version to run our tests.

Now both the .NET tests and the Node.js tests are running together.

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMIfamily. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.

To learn more, read our about page, like/message us on Facebook, or simply, tweet/DM @HackerNoon.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!