In .travis.yml, we must first specify the primary language our project is written in. This allows Travis to install the required dependencies, and use appropriate default settings and configurations. For example, if we specify that our project is written in Node.js, Travis will, by default, configure itself to install dependencies by running npm install, and test the application by running npm test. It'll also look for a yarn.lock file at the root directory, and if it's present, use the yarn install and yarn run test commands instead.
Therefore, add the following line inside our .travis.yml file to inform Travis that this project uses Node.js:
language: node_js
With Node.js, you can also specify which version of Node.js (or io.js) you want the build and tests to run on. You can specify Node versions by their major, minor, and patch versions, and it will get the latest version that satisfies that criteria. You can also use the string "node" to get the latest stable Node.js release, or "lts/*" for the latest LTS Node.js release.
Since this is a server-side application, we have control over the environment our application is run in. Therefore, if we want to, we can run our test only against the Node.js version specified in the .nvmrc file (8.11.4). However, since this process is automated, and Travis can run these tests in parallel, the cost of running additional tests is very low. Therefore, we should run our tests against future Node.js versions; doing so will prevent deprecated syntax from being introduced into our project.
Therefore, update our .travis.yml to the following:
language: node_js
node_js:
- "node"
- "lts/*"
- "8"
- "8.11.4"