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.
Unit testing is the first software testing phase in SDLC and it is usually taken up during the development of the application. These unit test cases are written and executed by software developers.
99% of all meteorites are attracted to a strong magnet. (As are metal artifacts, slag and iron ore) Or if the object is small, hang it or the magnet from a string. This is used as a preliminary test and is recommended to new collectors. If your specimen does not pass this test it is probably NOT a common meteorite!
Running acceptance tests To run acceptance tests, we simply need to start our Meteor app as usual, and point Chimp at it. The chimp-watch command will then run the test in a browser, and continue to re-run it as we change the test or the application. (Note that the test assumes we are running the app on port 3000 ).
Unit tests are standalone, can be run in isolation, and have no dependencies on any outside factors such as a file system or database. Repeatable. Running a unit test should be consistent with its results, that is, it always returns the same result if you do not change anything in between runs.
Place your tests in the tests/
folder. Unlike Rails, which uses a folder named test
for this purpose, Meteor uses the plural tests
for this folder name.
Assets stored in a folder named "tests" will be completely ignored by Meteor; these assets will not be loaded on the client or server.
Ironically, I was tipped off by someone having the opposite issue who wants their tests loaded by the Meteor client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With