Hi I am trying to do a mocha test on my meteor app. My code is below for testing.
describe("logged in admin insertion test", function() {
before(function(done) {
Meteor.loginWithPassword('[email protected]', 'password', done)
})
data ={
item: 'something new'
}
it("Should allow inserting data", function(done) {
chai.expect(Meteor.call.bind(Meteor, 'addNewMenu', data)).to.not.throw(Error);
done();
})
})
I read that loginWithPassword is only available in client side of meteor. But I see few examples being done like this.
Since loginWithPassword is async I added an async version aswell
describe("logged in admin insertion test", function() {
before(function(done) {
Meteor.loginWithPassword('[email protected]', 'password', function(err, res) {
data ={
item: 'something new'
}
it("Should allow inserting data", function(done) {
chai.expect(Meteor.call.bind(Meteor, 'addNewMenu', data)).to.not.throw(Error);
done();
})
})
})
})
Is there any other way of simulating logged in user? Am I doing something wrong here? Thank you for help
Yes there is. Check this:
Server side:
Client side
Source : https://dweldon.silvrback.com/impersonating-a-user