Full-Stack Web Development with Vue.js and Node

(singke) #1
Going Live Chapter 10

Create .travis.yml file in the application in the root:


// travis.yml
language: node_js
node_js:


  • "10.0.0"


Now, this code block tells that this is a Node.js project and that the version of Node.js for


this project is 10.0.0. You have to specify the Node.js that is installed in your application.


You can check the version with the following:


$ node -v

You can specify the same version in the .travis.yml file as well.


If the specified version is not a standard or available version of Node.js, then an error is
raised.


We can also specify the version of Node.js that we want to use to build the project in a file


called .nvmrc. The travis.yml file reads the content of this file if the version is not


specified in the .travis.yml file itself.


Building the script

Now the next part is to tell Travis to run the test suites. This part is specified in the


script key in the .travis.yml file. The default build script for a Node.js project is npm


test. But let's first start with adding a single command to run in a single file so that it's


quick. Update the content of the .travis.yml file with the following:


language: node_js
node_js:


  • "10.0.0"
    script: npm run unit


This tells the script to run the unit tests when any change is made to the repository.

Free download pdf