I have an app where some admin users are created in server/fixtures.js. For various reasons these admin accounts form the basis of a complex user validation network. I want to write some tests to assert that everything is ok.
So I have:
accounts-password 1.1.1 Password support for accounts
sanjo:jasmine 0.12.7 Easily use Jasmine in Meteor
velocity:html-reporter 0.4.2 Reactive Velocity test reports in your app.
but:
var id = Accounts.createUser({
username: "MyUser",
password: "password"
});
console.log("id: " + id);
returns “id: undefined”
I know that I could create these admin users in a beforeAll but then I wouldn’t be testing the app.
So, when the app starts loads of code in server/fixtures.js starts failing to compile because it needs valid userId’s of the admin users mentioned in my original post.
If I remove jasmine and install nightwatch then my fixtures.js code runs ok but I lose the fine grained unit testing that I need. It seems that I need for my fixtures.js code to be aware when it’s being run by jasmine and avoid doing it’s stuff.
For anyone else reading this in the future, the cleanest solution that I could come up with is to wrap all the db fixture stuff in an if(Meteor.release) {… which of course the mocks return as undefined.