🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@anton-johansson/smtp-mock-server

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anton-johansson/smtp-mock-server

Provides a mock SMTP server that can be used to verify and look at e-mails in end-to-end test. It provides a JSON API to await received e-mails.

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

SMTP mock server

Provides a mock SMTP server that can be used to verify and look at e-mails in end-to-end test. It provides a JSON API to await received e-mails.

Running

$ npx @anton-johansson/smtp-mock-server

Options

SwitchDescription
--smtp-port <port>The port to serve the SMTP server on. Defaults to 3025.
--api-port <port>The port to serve the API on. Defaults to 3080.

Example setup

package.json:

{
  "scripts": {
    "start": "node dist/index.js",
    "test:e2e": "npx playwright test",
    "test:e2e-ci": "start-test start 3000 'npx @anton-johansson/smtp-mock-server' 3080 test:e2e"
  },
  "devDependencies": {
    "start-server-and-test": "2.0.0"
  }
}

Then simply run npm run test:e2e-ci on your continuous integration server. It will fire up your server, the SMTP mock server, run the tests and then shut down the servers again.

API

Await e-mail

$ curl http://localhost:3080/await-email?subject=Hello

Parameters

Query parameter keyDescription
subjectOptional subject to filter by when awaiting e-mail.
timeoutThe number of milliseconds to wait for the e-mail. Defaults to 5000.
removeWhether or not to remove the email from the list after receiving it. Defaults to true.

Clear e-mails

This one is not really useful during the actual end-to-end tests, but it can be useful to clear the e-mails before starting the tests when running tests locally.

$ curl -XPOST http://localhost:3080/clear-emails

FAQs

Package last updated on 19 Aug 2023

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