Chimp, findOne inside server.execute throwing error


#1

I’m trying to write some tests with chimp, i’m following this great article from ryan https://themeteorchef.com/tutorials/acceptance-testing-basics-with-chimp

only difference is I have collection in imports/collections/Invites.js

import { Mongo } from ‘meteor/mongo’;

const Invites = new Mongo.Collection('invites');
export default Invites;

my test case is below

describe('Request Invite', function () {
  beforeEach(function () {
    server.execute(function () {
      const Invites = require('/imports/collections/Invites.js');

      const invite = Invites.findOne({ email: 'carl.winslow@abc.com' });
      if (invite) {
        Invites.remove(invite._id);
      }
    });
  });
});

I’m getting following error

I have other test case, which is working fine

/* eslint-env mocha */
/* eslint-disable func-names, prefer-arrow-callback, global-require */

describe('Log In', function () {
  beforeEach(function () {
    server.execute(function () {
      const { Meteor } = require('meteor/meteor');

      const user = Meteor.users.findOne({ 'emails.address': 'carl.winslow@abc.com' });
      if (user) {
        Meteor.users.remove(user._id);
      }
    });
  });

  it('should allow us to login @watch', function () {
    server.execute(function () {
      const { Accounts } = require('meteor/accounts-base');

      Accounts.createUser({
        email: 'carl.winslow@abc.com',
        password: 'bigguy1989',
        profile: {
          name: { first: 'Carl', last: 'Winslow' },
        },
      });
    });

    browser.url('http://localhost:3000/')
           .setValue('#email', 'carl.winslow@abc.com')
           .setValue('#password', 'bigguy1989')
           .submitForm('form');

    browser.waitForExist('#side-menu');
    expect(browser.getUrl()).to.equal('http://localhost:3000/dashboard');
  });
});

I think the issue is with importing collection, anyone had any success with this?

Thanks in advance.