mn

mock-nodemailer

A small framework to mock out nodemailer in your tests

Showing:

Popularity

Downloads/wk

69

GitHub Stars

7

Maintenance

Last Commit

8yrs ago

Contributors

2

Package

Dependencies

2

Size (min+gzip)

78.9KB

License

BSD-2-Clause

Type Definitions

Tree-Shakeable

No?

Categories

Deprecated!
this package is no longer maintained and propably broken

Readme

mock-nodemailer

Build Status

A small framework to mock out nodemailer in your tests.

Usage

test('email gets sent', function(done) {

    var email = {
        to: Faker.Internet.email(),
        text: Faker.Lorem.sentence(),
        subject: Faker.Lorem.sentence()
    };

    mockMailer.expectEmail(email, done);

    transport.sendMail(email, function() {});

});

test('email gets sent, throwing if an email is not ours', function(done) {

    var email = {
        to: Faker.Internet.email(),
        text: Faker.Lorem.sentence(),
        subject: Faker.Lorem.sentence()
    };

    mockMailer.mock(function(sentEmail) {
        assert.deepEqual(email, sentEmail);
        return true;
    }, done);

    transport.sendMail(email, function() {});

});

test('email gets sent, returning falsy if an email is not ours', function(done) {

    var email = {
        to: Faker.Internet.email(),
        text: Faker.Lorem.sentence(),
        subject: Faker.Lorem.sentence()
    };

    mockMailer.expectEmail(function(sentEmail) {
        return _.isEqual(email, sentEmail);
    }, done);

    transport.sendMail(email, function() {});

});

test('multiple emails get sent', function(done) {

    var email = {
        to: Faker.Internet.email(),
        text: Faker.Lorem.sentence(),
        subject: Faker.Lorem.sentence()
    };

    mockMailer.expectEmail(5, function(sentEmail) {
        return _.isEqual(email, sentEmail);
    }, done);

    _.times(5, function() {
        transport.sendMail(email, function() {});
    });

});

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100