How to write unit tests for Meteor server code?

I have server-side code - meteor methods and simple helper assistants - that I would like to test. I read documentation testing with Meteor, but it's hard for me to connect the documentation to my very simple use case. Can someone share with me how they tested the meteor method or a simple JS function?

For example, let's say you have some kind of server-side method, some_methods.js

function someHelper() { // does lots of cool stuff }; Meteor.methods({ 'user/update' (userProperties) { // updating some user properties someHelper(); } }) 
+7
unit-testing meteor backend
source share
1 answer

We have developed unit and integration tests for our open source RadGrad application ( https://radgrad.org ).

For more information about how we conduct unit and integration testing, see:

https://www.radgrad.org/docs/developer-guide-testing.html

Here is an example of a unit (server-side only) test:

https://github.com/radgrad/radgrad/blob/master/app/imports/api/career/CareerGoalCollection.test.js

And here is an example of an integration (client + server) test:

https://github.com/radgrad/radgrad/blob/master/app/imports/api/career/CareerGoalCollection.methods.app-test.js

We do not have extensive user interface tests; you need to use something like Selenium for this. Testing the user interface in Meteor is no different from testing the user interface for any other web application.

+2
source share

All Articles