Wylio / meteor-mandrill

Meteor package for sending email via Mandrill
https://atmospherejs.com/wylio/mandrill
32 stars 8 forks source link

Package is not working properly in test mode #23

Open ksendra opened 7 years ago

ksendra commented 7 years ago

Hi, I'm trying to run meteor tests to test some of functionality that uses Your Mandrill package - and it seems that the package does not load correctly in test mode. I'm using practicalmeteor:mocha for tests. Mandrill.messages.sendTemplate usage returns 'Cannot read property 'sendTemplate' of undefined' and the console.log of Mandrill returns { options: {}, config: [Function], sendTemplate: [Function] } while in non-test mode it's much larger. Any suggestions on how to get this working?

Floriferous commented 7 years ago

Running into this issue as well, wonder why sendTemplate is now part of the Mandrill object.

Floriferous commented 6 years ago

In case anyone is wondering, you need to explicitly call Mandrill.config({ ...yourOptions }) before your tests, as meteor won't load the file where you are doing this for the non-test app.

So simply import it in a place that gets run before your tests start. This would be a working hack:

Mandrill.config({});

describe('my email tests', () => {
  it('works', () => {
    // Your tests
  })
})