updated jest to sort of work with es6

This commit is contained in:
Aster Fialla
2026-02-17 17:38:06 -05:00
parent 35b454bc80
commit ba9552b4aa
5 changed files with 34 additions and 11 deletions

View File

@@ -22,15 +22,21 @@
"jest": "^30.2.0"
},
"scripts": {
"test": "jest"
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
},
"jest": {
"testEnvironment": "node",
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"moduleFileExtensions": ["js", "json"],
"testMatch": ["**/__tests__/**/*.js", "**/?(*.)+(spec|test).js"],
"moduleFileExtensions": [
"js",
"json"
],
"testMatch": [
"**/__tests__/**/*.js",
"**/?(*.)+(spec|test).js"
],
"verbose": true
}
}

2
tests/env.jest Normal file
View File

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

View File

@@ -1,12 +1,14 @@
jest.mock('@fluxerjs/core', () => jest.fn());
jest.mock('../../src/db.js', () => jest.fn());
jest.mock('sequelize', () => jest.fn());
jest.mock('../../src/enums.js', () => ({
enums: jest.requireActual('../../src/enums.js')
}));
import {jest} from "@jest/globals";
const {enums} = require("../../src/enums.js");
const memberHelper = require("../../src/helpers/memberHelper.js");
jest.unstable_mockModule('@fluxerjs/core', () => jest.fn());
jest.unstable_mockModule('../../src/db.js', () => jest.fn());
jest.unstable_mockModule('sequelize', () => jest.fn());
const { EmbedBuilder } = await import ("@fluxerjs/core");
const { database } = await import('../../src/db.js');
const { EmptyResultError, Op } = await import ('sequelize');
import { enums } from "../../src/enums.js";
import { memberHelper } from "../../src/helpers/memberHelper.js";
describe('parseMemberCommand', () => {

11
tests/jest.config.js Normal file
View File

@@ -0,0 +1,11 @@
/** @type {import('jest').Config} */
const config = {
clearMocks: true,
collectCoverage: true,
coverageDirectory: "coverage",
setupFiles: ["<rootDir>/jest.setup.js"], // path to a setup module to configure the testing environment before each test
transform: {},
verbose: true,
};
export default config;

2
tests/jest.setup.js Normal file
View File

@@ -0,0 +1,2 @@
import * as dotenv from "dotenv";
dotenv.config({ path: "env.jest" });