Testing server fixtures for admin users

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.

Any suggestions welcome.

Thanks
Rob

Update: velocity or jasmine are adding stubs into the tests folder.

While not entirely unexpected behaviour for a unit testing suite :slight_smile: stubs are being automatically added into the following folders:

tests/jasmine/server/unit/package-stubs.js
tests/jasmine/server/unit/packageMocksSpec.js

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.

You can use the Server Integration mode of sanjo:jasmine to validate the contents of the database.

In the server unit mode Meteor is mocked. This is the mock: https://github.com/meteor-velocity/meteor-stubs/blob/master/index.js

Thanks @Sanjo.

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.