I’m trying to do a acceptance-test, but I have to use Meteor.userId(). So I thought I should use sinon and stub. But I do get the error Error: Cannot find module 'meteor/practicalmeteor:sinon', which I do not understand, as I’m importing this:
import { sinon } from 'meteor/practicalmeteor:sinon';
describe('Chimp Mocha', () => {
let sandbox;
beforeEach(function() {
sandbox = sinon.sandbox.create();
});
afterEach(function() {
sandbox.restore();
});
describe('logged user', () => {
it('should get some data @watch', () => {
sandbox.stub(Meteor, 'userId').returns('42');
});
});
});
Chimp.js runs outside of the Meteor ecosystem. I’m pretty sure that means it can’t use Meteor packages directly (which means it can’t use meteor/X based imports, since these are interpreted and handled by the Meteor build tool). You might want to look into using sinon directly from npm instead.
To use sinon from npm with Meteor, you would have to npm install it first:
meteor npm install --save-dev sinon
That being said, the process with Chimp is likely different (since again Chimp runs outside of Meteor). You’ll likely have to set this up a bit differently (well, not that differently since you’ll still need to npm install sinon somewhere and have it picked up by Chimp). I’m not overly familiar with Chimp, so maybe @sam can help.
as @hwillson has alluded, Chimp runs outside the Meteor context. It’s actually just a node application that combines a set of tools to give you easy end-to-end testing capability.
So when stubbing / calling Meteor specific things, you can’t do those directly from Chimp (though you can use server.execute(fn) to run arbitrary code on Meteor from within a Chimp test).