From a4804c2ea7cf1e7f86ed2668815b42191cc61e07 Mon Sep 17 00:00:00 2001 From: Aster Fialla Date: Tue, 17 Feb 2026 20:48:44 -0500 Subject: [PATCH] added babel to convert es modules to cjs --- babel.config.js | 8 ++++++++ tests/jest.config.js => jest.config.js | 12 ++++++------ package.json | 22 +++++----------------- tests/jest.setup.js | 2 -- 4 files changed, 19 insertions(+), 25 deletions(-) create mode 100644 babel.config.js rename tests/jest.config.js => jest.config.js (65%) delete mode 100644 tests/jest.setup.js diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..3c6cd52 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,8 @@ +// babel.config.js +module.exports = { + env: { + test: { + plugins: ["@babel/plugin-transform-modules-commonjs"] + } + } +}; \ No newline at end of file diff --git a/tests/jest.config.js b/jest.config.js similarity index 65% rename from tests/jest.config.js rename to jest.config.js index bdee2b6..cd625d7 100644 --- a/tests/jest.config.js +++ b/jest.config.js @@ -1,11 +1,11 @@ -/** @type {import('jest').Config} */ -const config = { +// jest.config.js +module.exports = { clearMocks: true, collectCoverage: true, coverageDirectory: "coverage", setupFiles: ["/jest.setup.js"], // path to a setup module to configure the testing environment before each test - transform: {}, verbose: true, -}; - -export default config; + transform: { + "^.+\\.[t|j]sx?$": require.resolve('babel-jest') + }, +}; \ No newline at end of file diff --git a/package.json b/package.json index eea7e3a..316602c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,6 @@ "version": "1.0.0", "description": "", "main": "src/bot.js", - "type": "module", "repository": { "type": "git", "url": "https://github.com/pieartsy/PluralFlux.git" @@ -19,24 +18,13 @@ "tmp": "^0.2.5" }, "devDependencies": { + "@babel/core": "^7.29.0", + "@babel/plugin-transform-modules-commonjs": "^7.28.6", + "@babel/preset-env": "^7.29.0", + "babel-jest": "^30.2.0", "jest": "^30.2.0" }, "scripts": { - "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" - ], - "verbose": true + "test": "jest" } } diff --git a/tests/jest.setup.js b/tests/jest.setup.js deleted file mode 100644 index f44af1b..0000000 --- a/tests/jest.setup.js +++ /dev/null @@ -1,2 +0,0 @@ -import * as dotenv from "dotenv"; -dotenv.config({ path: "env.jest" });