[SOLVED] Require Meteor in unit chai test

We are writing chai tests.
One test is expecting to throw an error.
The problem is that our code throw an error like this

throw new Meteor.error('err', 'my-error')

but in chai tests Meteor is undefined.

The only way to do it was like this :

if (typeof Meteor !== 'undefined') {
        throw new Meteor.Error('err', 'my-error');
      throw 'my-error';

It seems strange that I have to do this in my code, is it possible to import/require Meteor at the top of my function ?


maybe you can mock it in some ‘setup’ functions like Meteor = { Error : Error }; ?

1 Like

Thanks a lot, this is clever !

Meteor = {
    Error : function() {
        throw arguments['1'];

worked perfectly ! (added on top of our test file)