test: mock nodemailer network calls (#9957)
In tests, nodemailer was making network calls to create test accounts using ethereal.email. This mocks them appropriately.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import console from 'console'
|
||||
global.console = console
|
||||
|
||||
import nodemailer from 'nodemailer'
|
||||
|
||||
import { generateDatabaseAdapter } from './generateDatabaseAdapter.js'
|
||||
|
||||
process.env.PAYLOAD_DISABLE_ADMIN = 'true'
|
||||
@@ -11,6 +13,18 @@ process.env.PAYLOAD_PUBLIC_CLOUD_STORAGE_ADAPTER = 's3'
|
||||
process.env.NODE_OPTIONS = '--no-deprecation'
|
||||
process.env.PAYLOAD_CI_DEPENDENCY_CHECKER = 'true'
|
||||
|
||||
// Mock createTestAccount to prevent calling external services
|
||||
jest.spyOn(nodemailer, 'createTestAccount').mockImplementation(() => {
|
||||
return Promise.resolve({
|
||||
imap: { host: 'imap.test.com', port: 993, secure: true },
|
||||
pass: 'testpass',
|
||||
pop3: { host: 'pop3.test.com', port: 995, secure: true },
|
||||
smtp: { host: 'smtp.test.com', port: 587, secure: false },
|
||||
user: 'testuser',
|
||||
web: 'https://webmail.test.com',
|
||||
})
|
||||
})
|
||||
|
||||
const dbAdapter = process.env.PAYLOAD_DATABASE || 'mongodb'
|
||||
|
||||
generateDatabaseAdapter(dbAdapter)
|
||||
|
||||
Reference in New Issue
Block a user