imported env files better

This commit is contained in:
Aster Fialla
2026-02-23 12:27:25 -05:00
parent 6638756a9a
commit 10c145a02d
4 changed files with 10 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
**/.dockerignore
**/.env
.env.jest
**/.git
**/.gitignore
**/.project

2
.env.jest Normal file
View File

@@ -0,0 +1,2 @@
FLUXER_BOT_TOKEN=jest-fluxer-bot-token
POSTGRES_PASSWORD=jest-postgres-password

View File

@@ -3,12 +3,12 @@ import { messageHelper } from "./helpers/messageHelper.js";
import {enums} from "./enums.js";
import {commands} from "./commands.js";
import {webhookHelper} from "./helpers/webhookHelper.js";
import * as env from 'dotenv';
import env from 'dotenv';
import {utils} from "./helpers/utils.js";
env.config();
env.config({path: './.env'});
const token = process.env.FLUXER_BOT_TOKEN;
export const token = process.env.FLUXER_BOT_TOKEN;
if (!token) {
console.error("Missing FLUXER_BOT_TOKEN environment variable.");
@@ -84,6 +84,7 @@ export const debounceLogin = utils.debounce(client.login, 60000);
(async () => {
try {
await client.login(token);
// await db.check_connection();
} catch (err) {

View File

@@ -1,4 +1,4 @@
const env = require('dotenv');
const env = require('dotenv').config({path: './.env.jest'})
const {enums} = require("../src/enums.js");
jest.mock('@fluxerjs/core', () => {
@@ -59,12 +59,9 @@ const {commands} = require("../src/commands.js");
const {webhookHelper} = require("../src/helpers/webhookHelper.js");
const {utils} = require("../src/helpers/utils.js");
let {handleMessageCreate, client, debounceLogin} = require("../src/bot.js");
env.config();
let {handleMessageCreate, client} = require("../src/bot.js");
describe('bot', () => {
beforeEach(() => {
jest.resetModules();
jest.clearAllMocks();
@@ -74,6 +71,7 @@ describe('bot', () => {
test('on message creation, if message is from bot, return', () => {
// Arrange
console.log(env)
const message = {
author: {
bot: true