Setting up Travis.yml tests with RethinkDB

Because you’re a good developer, you often write tests for the code you’re writing. Because you’re a really good developer, you often use tools like Travis CI for continuous integration.

So you probably google “travis ci rethinkdb” and find an example for running RethinkDB in Travis CI in their website.

Travis Screenshot

After adding this to your .travis.yml, making your tests pass locally, and then pushing your changes to GitHub you see the following on Travis:

Your tests fail! But they worked locally! What’s going on!

If you look at RethinkDB’s documentation, you’ll see that the instructions for installing RethinkDB are a bit different from the Travis CI example. The repository posted in Travis CI’s website is outdated and installs an older version of RethinkDB that is probably different from your client driver version (which is what causes the problem).

RethinkDB Install Page

Fixing this is pretty simple. Just copy paste the commands posted on the RethinkDB install page into your .travis.yml file.

  - source /etc/lsb-release && echo "deb $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
  - wget -qO- | sudo apt-key add -
  - sudo apt-get update -q
  - sudo apt-get -y --force-yes install rethinkdb

    - rethinkdb --daemon