mapbox/tm2 — pull request #316 by rclark (2014-04-22 23:33:26+00:00)
Title: Tests cleanup

I wanted to be able to run `npm test` and run both front and backend tests. I didn't like that the steps to running the frontend tests were hidden in .travis.yml. That meant writing a [`test-runner.sh`](https://github.com/mapbox/tm2/blob/travis-cleanup/test/test-runner.sh), adjusting `.travis.yml` and then Travis led me down a little rabbit hole.

1. @tristen: some of the other refactoring I've done to the style routes has meant there is a distinct difference between *making a style* and *loading a style*. As a result I have to [make a call to create a temporary style before I can load it up for tests](https://github.com/mapbox/tm2/blob/travis-cleanup/test/test-runner.sh#L18-L23). I wonder how you feel about this?

2. @yhahn: I found that if I `rm -rf ~/.tilemill/v2/cache` and then ran `mocha -R spec`, that tests that involved loading a source in any way would fail. This is because the `tm` object is configured by the test scripts *after* [these caching modules are `require`d](https://github.com/mapbox/tm2/blob/master/lib/source.js#L15-L16). As a result calls to `tm.config` are unlikely to behave the way you expect them too if you've already required `style.js` or `source.js`. I changed `source.js` so that the caching objects initialize more on-demand-ish. Please have a look and make sure you don't see any hidden negative consequences.