Is there a place where my tests can live without being run by Meteor?
I just started my first Meteor project, and began by writing unit tests with Mocha and should.js. Though mocha runs without a problem, the tests prevent Meteor from starting up since it has issues using node's require
instead of __meteor_bootstrap__.require
(full error message).
That being said, Meteor should not be running my tests! According to the Meteor documentation, code can only be placed on the client, server, or both. Unit test suites do no belong in these categories, and I am not the only person confused by Meteor's lack of a well-defined location for placing automated tests.
Right now, my tests are kept in server/test/
, with the contents of each file wrapped in the block:
if (typeof(Meteor) === 'undefined') { ... }
While this works, it does not feel elegant. Do you have any other suggestions for structuring your tests with your Meteor app?
Update: in lieu of explicit instructions in the Meteor docs, I followed the Rails folder conventions (4th paragraph), using a folder called test
for storing my testing assets. I later moved this to server/test
since I did not want it loaded on the client.