I\'m having a nightmare writing unit tests for meteor. There are too many old, outdated articles and too few clear, relevant pieces of documentation for me to be able to wor
I think you need to stud the Meteor.user()
method, try this:
import { Meteor } from 'meteor/meteor';
import { resetDatabase } from 'meteor/xolvio:cleaner';
import { sinon } from 'meteor/practicalmeteor:sinon';
describe('...', () => {
let currentUser;
beforeEach(() => {
resetDatabase();
Factory.define('user', Meteor.users, {
profile: {
// ...
},
});
currentUser = Factory.create('user');
sinon.stub(Meteor, 'user');
Meteor.user.returns(currentUser);
});
afterEach(() => {
Meteor.user.restore();
resetDatabase();
});
it('...', () => {
// ...
});
});
You need to add these packages: dburles:factory
, xolvio:cleaner
, practicalmeteor:sinon