Skip to content

Commit 5aceaec

Browse files
test(email-nodemailer): use a local transport in integration tests (#19022)
Backports the Nodemailer integration-test transport change from #19013 to `3.x`.
1 parent 8b31ddf commit 5aceaec

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎test/email-nodemailer/config.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from 'path'
33
const filename = fileURLToPath(import.meta.url)
44
const dirname = path.dirname(filename)
55
import { nodemailerAdapter } from '@payloadcms/email-nodemailer'
6+
import nodemailer from 'nodemailer'
67

78
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
89
import { devUser } from '../credentials.js'
@@ -14,7 +15,19 @@ export default buildConfigWithDefaults({
1415
},
1516
},
1617
collections: [],
17-
email: nodemailerAdapter(),
18+
// Integration tests run offline; local development keeps the Ethereal inbox.
19+
email: nodemailerAdapter(
20+
process.env.VITEST === 'true'
21+
? {
22+
defaultFromAddress: '[email protected]',
23+
defaultFromName: 'Test',
24+
skipVerify: true,
25+
transport: nodemailer.createTransport({
26+
jsonTransport: true,
27+
}),
28+
}
29+
: undefined,
30+
),
1831
onInit: async (payload) => {
1932
if (process.env.SKIP_ON_INIT !== 'true') {
2033
await payload.create({

0 commit comments

Comments
 (0)