Boa tarde, estou tentando fazer o teste do e-mail, utilizando as credenciais disponibilizada no projeto do curso, mas na hora de rodar o teste não é possível autenticar. Tem alguma outra credencial que posso utilizar? Ou errei em alguma parte do código?
(node:38834) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use node --trace-warnings ...
to show where the warning was created)
FAIL src/test/config/disparoEmail.test.js
Testando disparo de email
✕ O sistema deve validar a conexão com o sistema de disparo de email (731 ms)
● Testando disparo de email › O sistema deve validar a conexão com o sistema de disparo de email
Invalid login: 535 Authentication failed
at SMTPConnection._formatError (node_modules/nodemailer/lib/smtp-connection/index.js:790:19)
at SMTPConnection._actionAUTHComplete (node_modules/nodemailer/lib/smtp-connection/index.js:1548:34)
at SMTPConnection.<anonymous> (node_modules/nodemailer/lib/smtp-connection/index.js:546:26)
at SMTPConnection._processResponse (node_modules/nodemailer/lib/smtp-connection/index.js:953:20)
at SMTPConnection._onData (node_modules/nodemailer/lib/smtp-connection/index.js:755:14)
at TLSSocket.SMTPConnection._onSocketData (node_modules/nodemailer/lib/smtp-connection/index.js:193:44)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 0.964 s, estimated 3 s
Ran all test suites matching /src/test/config/disparoEmail.test.js/i.
disparoEmail.test.js
import { describe, expect, it } from '@jest/globals';
import nodemailer from 'nodemailer';
import 'dotenv/config';
const transporter = nodemailer.createTransport({
host: process.env.HOST_EMAIL,
port: 587,
secure: false, // upgrade later with STARTTLS
auth: {
user: process.env.USER_EMAIL,
pass: process.env.PASS_EMAIL,
},
});
const verificaConexao = () => new Promise((resolver, reject) => {
transporter.verify((error, success) => {
if (error) {
reject(error);
} else {
resolver(success);
}
});
});
describe('Testando disparo de email', () => {
it('O sistema deve validar a conexão com o sistema de disparo de email', async () => {
const estaConectado = true;
const validarConexao = await verificaConexao();
expect(validarConexao).toStrictEqual(estaConectado);
});
});
.env
HOST_EMAIL=smtp.ethereal.email
USER_EMAIL=l4fb7ukamgjlh2f6@ethereal.email
PASS_EMAIL=1WRdhg3EGfXtfW5XFQ
Project no GitHub
https://github.com/fmatheusm/nodejs-api-teste