Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks
https://atmospherejs.com/matb33/collection-hooks
MIT License
657 stars 92 forks source link

Enable automatic testing on this package with Travis #35

Closed mizzao closed 10 years ago

mizzao commented 10 years ago

Hi @matb33,

I just fixed the tests in this package for 0.7.2 in 81248850ac0b61a2e386b6fc50a01cde43b497ec.

Since this package has Tinytest set up, it would be sweet to set up automatic testing. It just requires a few things:

  1. Enroll your GitHub account at https://travis-ci.org and enable automatic testing for this repo
  2. Add the following to the root of the repo as .travis.yml:

    language: node_js
    node_js:
     - "0.10"
    before_install:
     - "curl -L http://git.io/ejPSng | /bin/sh"
  3. (optional): Add the cool little build badge with this Markdown in the README:

    [![Build Status](https://travis-ci.org/matb33/meteor-collection-hooks.png?branch=master)](https://travis-ci.org/matb33/meteor-collection-hooks)
  4. Push the new commit.

For more information see https://github.com/arunoda/travis-ci-meteor-packages. I have this running for https://github.com/mizzao/meteor-user-status, here: https://travis-ci.org/mizzao/meteor-user-status. The integration is really nice, you get the nice little badge that shows everything is working, and you don't have to meteor test-packages yourself!

Plus there is the added benefit that tests are run for all pull requests, so if everything passes and it doesn't look kooky, you can just auto merge. Saves a lot of work!

matb33 commented 10 years ago

@mizzao nice, didn't realize it was that easy! I'm all for it -- are you OK with making this change? I connected up my GitHub account with Travis, and flipped the switch on the collection-hooks repo. Would you need anything else?

mizzao commented 10 years ago

@matb33 Tests are added, but the find/findOne userId tests have some non-deterministic behavior where they may fail on the first page load. It seems like they fail every time when testing in console. I didn't used to care about this because before, re-running the tests would make them pass, but I'm going to figure out how to fix them so that everything passes in Travis.

Need to get rid of that poopy "build failing" badge as soon as possible :)

matb33 commented 10 years ago

Nice, if you fix this you'll at least be worthy of a "tinytest master" badge :)

mizzao commented 10 years ago

What can I say, I am a tinytest master: https://travis-ci.org/matb33/meteor-collection-hooks

I had to do something very interesting to get the synchronous tests to run with a login: https://github.com/matb33/meteor-collection-hooks/blob/master/tests/find_findone_userid.js#L75. But it was good practice, now I know how to make that work on my other packages too.

For future reference, the commands that need to be run for an automated test, to replicate what the travis package does, are

meteor test-packages --driver-package test-in-console collection-hooks

and then in a different terminal

URL="http://localhost:3000/" phantomjs $METEOR_HOME/packages/test-in-console/runner.js
matb33 commented 10 years ago

Awesome @mizzao, made my day!