Meteor Testing with Velocity & Jasmine

I understand you can use the Server Integration mode of sanjo:jasmine to validate the contents of the database.

I am testing the results of meteor method calls that insert, update, and remove from the database. My insert calls are working fine, but my update methods are not updating at all and it looks like a permission issue. I read that I can run this without logging in a user of which I was having a problem doing also.

Is there a way I can set the permissions for non logged in users so that my method calls will update documents in the database?

Thanks for your help!

When you execute database queries on the server, you always have permission to do it.
The tests are executed with a separate database. I think the name of the database is jasmine-server-integration.
Maybe something is wrong with your update query. Can you post it?

1 Like

Sure, sorry didn’t post it with my question. It updates correctly within my regular app.

Jasmine test:

describe ("create a new friend from Cindy to John", function( ) {
    it("should insert friend request", function( ) {
       var cindy = Meteor.users.findOne({username:"Cindy"});
       var john = Meteor.users.findOne({username:"John"});
       Meteor.call('requestInsert', cindy._id, john._id);
       var check = Friends.find({from_friend:cindy._id, to_friend:john._id}, {fields: {friend_status:1}});
       expect(check.map(function(a){return a.friend_status})).toMatch("RQ");
    });

    it("should update friend request", function( ) {
       var cindy = Meteor.users.findOne({username:"Cindy"});
       var john = Meteor.users.findOne({username:"John"});
       Meteor.call('requestUpdate', cindy._id, john._id);
       var check = Friends.find({from_friend:cindy._id, to_friend:john._id}, {fields: {friend_status:1}});
       expect(check.map(function(a){return a.friend_status})).toMatch("AC");
    });
});

Method calls:

requestInsert: function( fromFriend, toFriend){
   Friends.insert({
       from_friend: fromFriend,
       to_friend: toFriend,
       friend_status: "RQ"
   });
},
requestUpdate: function( fromFriend, toFriend){
   Friends.update({
       from_friend: fromFriend,
       to_friend: toFriend,
       friend_status: "RQ"}, 
       {$set:
           {'friend_status': "AC"}
        }
   });
}

It will be only one document record for each direction of fromFriend and toFriend. The first test passes, but the second test fails saying it expects “RQ” to match “AC”, so the document record still has “RQ” in it and it didn’t update friend status to “AC”. I also made sure the method was getting called by putting a test insert inside the method and my inserted document showed. I’m viewing the jasmine-server-integration database in RoboMongo. I’m running my jasmine tests on Windows localhost.

I found this topic on Stackoverflow, but having no luck following the answers.

In further testing, I found the issue! It simply wasn’t retrieving the correct record to update.

THANK YOU Sanjo for your help!!!