@reapit-cdk/email-receiver-client
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

@reapit-cdk/email-receiver-client

npm version npm downloads coverage: 99.02%25

This module helps you write tests which rely on receiving emails. Once you have set up @reapit-cdk/email-receiver, this module helps you interact with the dynamodb table it creates. You'll have to export the table arn and domain name from your stack and import them to be used here, using something like this.

Package Installation:

yarn add --dev @reapit-cdk/email-receiver-client
# or
npm install @reapit-cdk/email-receiver-client --save-dev

Usage

import { EmailReceiverClient } from '@reapit-cdk/email-receiver-client'
import { randomUUID } from 'crypto'

const emailClient = new EmailReceiverClient({
  // ...dynamoDbClient config
  tableArn: '', // imported emailReceiver.table.tableArn from cdk stack via export
})

const domainName = '' // imported emailReceiver.domainName from cdk stack via export

const recipient = `${randomUUID()}@${domainName}`

// ...
// Test code goes here that causes your system to send an email to that recipient
// ...

const emails = await emailClient.getRecipientEmails(recipient)
const emailWeWant = emails.find((message) => message.subject === "Something You're Testing")
if (!emailWeWant) {
  // retry a few times then throw error
}
// check emailWeWant.body is what you were expecting

Readme

Keywords

none

Package Sidebar

Install

npm i @reapit-cdk/email-receiver-client

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

451 kB

Total Files

5

Last publish

Collaborators

  • joshbalfour