You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue only seems to happen when upgrading to the pre-release version of VSCode which I did to fix another error I was previously having which was recommend by this github repo.
When I am initiating the resend library I am getting the following error.
FAIL src/app/api/survey/recruit/tests/recruit.test.ts [ src/app/api/survey/recruit/tests/recruit.test.ts ]
Error: Missing API key. Pass it to the constructor `new Resend("re_123")`
❯ new Resend node_modules/resend/dist/index.mjs:325:15
323| }
324| if (!this.key) {
325| throw new Error(
| ^
326| 'Missing API key. Pass it to the constructor `new Resend("re_123")`'
327| );
My implementation
import { beforeEach, expect, test } from "vitest";
import { loadEnvConfig } from "@next/env";
import { Resend } from "resend";
beforeEach(async () => {
loadEnvConfig(process.cwd());
});
test("send survey started / payment confirmed email", async () => {
const resend = new Resend(process.env.RESEND_API_KEY);
const generateId = () => Math.random().toString(36).substring(7);
const fakeSurveyId = generateId();
const fakePaymentIntent = "pi_" + generateId();
const { data, error } = await resend.emails.send({
from: "Some company <support@mycompany.com>",
to: "sam@mycompany.com",
subject: "Your survey is live!",
react: PaidSurveyLive({
survey: {
audience: "uk",
question:
"How likely are people to support a coffee brand that is environmentally friendly (test)",
size: 1,
id: fakeSurveyId,
},
paymentDetails: {
date: new Date().toDateString(),
discount: 0,
total: 7900,
paymentIntentId: fakePaymentIntent,
paymentMethod: {
type: "other",
last4: "4242",
},
subtotal: 7900,
tax: 0,
},
enviroment: process.env.NEXT_PUBLIC_ENVIROMENT === "production" ? "production" : "staging",
previewText: "Your survey is live! Click the button below to view your survey results.",
}),
});
expect(data).toBeDefined();
expect(error).toBeNull();
});
Reproduction
I'm not sure how I could reproduce this as it is related to local enviorment variables.
Hello @samducker. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.
I'm not sure how I could reproduce this as it is related to local enviorment variables.
I need a repository that I can open in VSCode and see the error. It doesn't matter if the code is the same that you have right now - you can use code from examples and create a reproducible repo there.
Describe the bug
This issue only seems to happen when upgrading to the pre-release version of VSCode which I did to fix another error I was previously having which was recommend by this github repo.
When I am initiating the resend library I am getting the following error.
My implementation
Reproduction
I'm not sure how I could reproduce this as it is related to local enviorment variables.
System Info
I'm using Next.js 14 with .env file
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: