# ts-smtp-test

> smtp server for integration testing

Latest version **1.0.8** (published 2020-05-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-smtp-test
pnpm add ts-smtp-test
yarn add ts-smtp-test
bun add ts-smtp-test
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2020-05-27 |
| First published | 2018-02-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 3 |
| Unpacked size | 16.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | martinmoeller |
| Keywords | smtp, test, typescript |

## Links

- npm: https://www.npmjs.com/package/ts-smtp-test
- Repository: https://github.com/normartin/ts-smtp-test
- Homepage: https://github.com/normartin/ts-smtp-test#readme
- Issues: https://github.com/normartin/ts-smtp-test/issues
- npm.io page: https://npm.io/package/ts-smtp-test

## Dependencies (3)

- [mailparser](https://npm.io/package/mailparser.md) ^2.7.7
- [smtp-server](https://npm.io/package/smtp-server.md) ^3.6.0
- [ts-retry-promise](https://npm.io/package/ts-retry-promise.md) ^0.4.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.0.8 (latest) — 2020-05-27
- 1.0.1-0 (next) — 2018-03-06
- 1.0.7 — 2020-04-04
- 1.0.6 — 2020-03-15
- 1.0.5 — 2019-07-18
- 1.0.4 — 2019-01-06
- 1.0.3 — 2018-03-22
- 1.0.2 — 2018-03-11
- 1.0.1 — 2018-03-10
- 1.0.0 — 2018-03-06
- 0.0.3 — 2018-02-26
- 0.0.2 — 2018-02-26
- 0.0.1 — 2018-02-23

## README

# ts-smtp-test #

[![Build status](https://github.com/normartin/ts-smtp-test/workflows/CI_build/badge.svg)](https://github.com/normartin/ts-smtp-test/actions)
[![Coverage Status](https://coveralls.io/repos/github/normartin/ts-smtp-test/badge.svg?branch=master)](https://coveralls.io/github/normartin/ts-smtp-test?branch=master)
[![Dependencies](https://david-dm.org/normartin/ts-smtp-test.svg)](https://david-dm.org/normartin/ts-smtp-test)
[![NPM](https://img.shields.io/npm/v/ts-smtp-test.svg?color=#555)](https://www.npmjs.com/package/ts-smtp-test)

SMTP server for integration tests.

Uses https://nodemailer.com/ as SMTP-Server.

```typescript
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

---
_Source: https://npm.io/package/ts-smtp-test · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
