Providers
Local
Print emails to the console instead of sending them.
The local provider doesn't send anything. It prints every email to the console and keeps a list of the sent messages, which makes it useful for development and tests.
import { createClient } from '@nicogenz/emails-sdk';
import { local } from '@nicogenz/emails-sdk/local';
const email = createClient({ provider: local() });
Options
| Option | Type | Default | Description |
|---|---|---|---|
log | boolean | true | Print each email to the console. |
Testing
Turn off the console output and check provider.sent in your assertions.
const provider = local({ log: false });
const email = createClient({ provider });
await email.send({
from: '[email protected]',
to: '[email protected]',
subject: 'Welcome',
text: 'Hi Jane',
});
expect(provider.sent).toHaveLength(1);
expect(provider.sent[0]).toMatchObject({ subject: 'Welcome' });