aboutsummaryrefslogtreecommitdiff
path: root/test/js
diff options
context:
space:
mode:
Diffstat (limited to 'test/js')
-rw-r--r--test/js/third_party/nodemailer/nodemailer.test.ts8
-rw-r--r--test/js/third_party/nodemailer/process-nodemailer-fixture.js21
2 files changed, 15 insertions, 14 deletions
diff --git a/test/js/third_party/nodemailer/nodemailer.test.ts b/test/js/third_party/nodemailer/nodemailer.test.ts
index 265112608..36a229524 100644
--- a/test/js/third_party/nodemailer/nodemailer.test.ts
+++ b/test/js/third_party/nodemailer/nodemailer.test.ts
@@ -2,10 +2,14 @@ import { test, expect, describe } from "bun:test";
import { bunRun } from "harness";
import path from "path";
+const it = process.env.SMTP_SENDGRID_KEY && process.env.SMTP_SENDGRID_SENDER ? test : test.skip;
describe("nodemailer", () => {
- test("basic smtp", async () => {
+ it("basic smtp", async () => {
try {
- const info = bunRun(path.join(import.meta.dir, "process-nodemailer-fixture.js"));
+ const info = bunRun(path.join(import.meta.dir, "process-nodemailer-fixture.js"), {
+ SMTP_SENDGRID_SENDER: process.env.SMTP_SENDGRID_SENDER as string,
+ SMTP_SENDGRID_KEY: process.env.SMTP_SENDGRID_KEY as string,
+ });
expect(info.stdout).toBe("true");
expect(info.stderr || "").toBe("");
} catch (err: any) {
diff --git a/test/js/third_party/nodemailer/process-nodemailer-fixture.js b/test/js/third_party/nodemailer/process-nodemailer-fixture.js
index a54735f26..49ab6a516 100644
--- a/test/js/third_party/nodemailer/process-nodemailer-fixture.js
+++ b/test/js/third_party/nodemailer/process-nodemailer-fixture.js
@@ -1,23 +1,20 @@
-import nodemailer from "nodemailer";
-const account = await nodemailer.createTestAccount();
+const nodemailer = require("nodemailer");
const transporter = nodemailer.createTransport({
- host: account.smtp.host,
- port: account.smtp.port,
- secure: account.smtp.secure,
+ host: "smtp.sendgrid.net",
+ port: 587,
+ secure: false,
auth: {
- user: account.user, // generated ethereal user
- pass: account.pass, // generated ethereal password
+ user: "apikey", // generated ethereal user
+ pass: process.env.SMTP_SENDGRID_KEY, // generated ethereal password
},
});
// send mail with defined transport object
let info = await transporter.sendMail({
- from: '"Fred Foo 👻" <foo@example.com>', // sender address
- to: "example@gmail.com", // list of receivers
+ from: process.env.SMTP_SENDGRID_SENDER, // sender address
+ to: process.env.SMTP_SENDGRID_SENDER, // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html body
});
-const url = nodemailer.getTestMessageUrl(info);
-console.log(typeof url === "string" && url.length > 0);
-transporter.close();
+console.log(typeof info?.messageId === "string");