Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-smtp-test

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-smtp-test

smtp server for integration testing

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ts-smtp-test

Build status Coverage Status Dependencies NPM

SMTP server for integration tests.

Uses https://nodemailer.com/ as SMTP-Server.

const server = new SmtpTestServer();

before(async () => {
    await server.start();
});

beforeEach(() => {
    server.clear();
});

after(async () => {
    await server.shutdown();
});

it("can receive mail", async () => {
    await sendMail(server.config, {
        attachments: [{content: "text attachment"}],
        from: "me@me.de",
        html: "some html",
        subject: "hi",
        text: "some text",
        to: "to@me.de",
    });

    expect(server.messages).length(1);

    const mail = server.messages[0];
    expect(mail.from).to.eq("me@me.de");
    expect(mail.to).to.eq("to@me.de");
    expect(mail.subject).to.eq("hi");
    expect(mail.textContent).to.eq("some text");
    expect(mail.htmlContent).to.eq("some html");
    expect(mail.attachments).length(1);
});

it("can wait for mails", async () => {
    setTimeout(() =>
        sendMail(server.config, {
                text: "1",
                to: "to@me.de",
            },
        ).catch(console.error), 5);

    setTimeout(() =>
        sendMail(server.config, {
                text: "2",
                to: "to@me.de",
            },
        ).catch(console.error), 10);

    // wait for 2 messages with a timeout of 15 millis
    const messages = await server.waitForMessages(2, 15);

    expect(messages).length(2);
    expect(messages[0].textContent).to.contain("1");
    expect(messages[1].textContent).to.contain("2");
});

Previous versions

Source: https://bitbucket.org/martinmo/ts-tools

Keywords

FAQs

Package last updated on 27 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc