filipedeschamps / rss-feed-emitter

Super RSS News Feed aggregator written in Node.js and ES6

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

13. Configure Travis CI for automated tests

filipedeschamps opened this issue · comments

Everyone loves Travis CI to automatically run your tests, it just works.

Create an account

Go to https://travis-ci.org/ and click on Sign up button. It will ask you to integrate with Github, give it access without worries.

Enable your repository

Navigate to your Profile Page, find the repository you want to enable and click in that switch button:

image

image

Environment variable

One more thing: remember I've said there's a safer way to integrate Code Climate and Travis? Great, we are going to pass the Code Climate's token through an Environment variable.

After you enable your module, click in that settings engine ( image ) and you will land in the repository settings page:

image

Notice the Environment Variables section. Add a new variable with this information:

Name: CODECLIMATE_REPO_TOKEN
Value: b84c2a82c59ba9f77fbd81c7b78b024a38bf6d5e3527dc4f819e1e1f1410e0b7

Obviously, change the token value with your own token and then click Add button.

Travis configuration file

You can tell Travis CI exactly what are you testing and in which versions you want to test it. Also, you can run commands after your tests finished to run (like sending coverage files to Code Climate).

So, create a .travis.yml file in the root of your repository with this content:

language: node_js
node_js:
  - "stable"
  - "5.0"
  - "4.2"
  - "0.12"
  - "0.10"
after_script:
  - npm install -g codeclimate-test-reporter
  - codeclimate-test-reporter < coverage/lcov.info

We are telling Travis CI:

  1. This is a Node.js application.
  2. We want to run our tests against stable, 5.0, 4.2, 0.12 and 0.10 Node.js versions.
  3. After the tests finishes, install codeclimate-test-reporter binary and then send to it the lcov.info coverage file. This binary will read CODECLIMATE_REPO_TOKEN environment variable to know to which account send the report.

Default test script

To run our tests, Travis CI will run the below command by default:

$ npm test

But we don't have nothing in our test script, since we just created a test-unit and coverage script. In the end, what we want is, when Travis CI runs the default test script, run the coverage script. So add this to your package.json file inside the scripts section:

"test": "npm run coverage"

Next step

14. Publish it to Github to test the integrations

Typo here:

"So, crate an .travis.yml file in the root of your repository with this content:"
I suppose it's missing the e.