Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

setupTest.ts 797 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  1. import { vi } from "vitest";
  2. import dotenv from "dotenv";
  3. import { resolve } from "path";
  4. import fs from "fs";
  5. // Load the .env file
  6. const envPath = resolve(__dirname, "../.env");
  7. dotenv.config({ path: envPath });
  8. // Read the .env file content
  9. const envContent = fs.readFileSync(envPath, "utf-8");
  10. // Parse the .env content
  11. const envVars = dotenv.parse(envContent);
  12. // Separate public and private variables
  13. const publicEnv = {};
  14. const privateEnv = {};
  15. for (const [key, value] of Object.entries(envVars)) {
  16. if (key.startsWith("PUBLIC_")) {
  17. publicEnv[key] = value;
  18. } else {
  19. privateEnv[key] = value;
  20. }
  21. }
  22. vi.mock("$env/dynamic/public", () => ({
  23. env: publicEnv,
  24. }));
  25. vi.mock("$env/dynamic/private", () => ({
  26. env: {
  27. ...privateEnv,
  28. MONGODB_URL: "mongodb://127.0.0.1:27017/",
  29. },
  30. }));
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...