Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

tests: Move Babel configuration into babel.config.js.

Anders Kaseorgff9e38228b15
diff --git a/eslint.config.js b/eslint.config.js
index 33605e52638..ca17d53cef1 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -193,7 +193,7 @@ export default defineConfig(
},
},
{
- ignores: ["**/*.cts", "**/*.mts", "**/*.ts"],
+ ignores: ["**/*.cts", "**/*.mts", "**/*.ts", "web/babel.config.js"],
extends: [tseslint.configs.disableTypeChecked],
rules: {
"@typescript-eslint/consistent-type-imports": "off",
diff --git a/web/babel.config.js b/web/babel.config.js
index ec95a8dfacf..5093c17c762 100644
--- a/web/babel.config.js
+++ b/web/babel.config.js
@@ -1,5 +1,9 @@
// @ts-check
+import path from "node:path";
+
+import _ from "lodash";
+
/** @type {Parameters<typeof import("babel-plugin-formatjs").default>[1]} */
const formatJsOptions = {
additionalFunctionNames: ["$t", "$t_html"],
@@ -15,7 +19,16 @@ const presetEnvOptions = {
/** @type {import("@babel/core").TransformOptions} */
const config = {
+ only: [new RegExp("^" + _.escapeRegExp(path.resolve(import.meta.dirname, "src") + path.sep))],
plugins: [["formatjs", formatJsOptions]],
presets: [["@babel/preset-env", presetEnvOptions], "@babel/typescript"],
+ env: {
+ test: {
+ plugins: [
+ ...(process.env["USING_INSTRUMENTED_CODE"] ? [["istanbul", {exclude: []}]] : []),
+ ["@babel/plugin-transform-modules-commonjs", {lazy: () => true}],
+ ],
+ },
+ },
};
export default config;
diff --git a/web/tests/lib/index.cjs b/web/tests/lib/index.cjs
index 963bef68fc4..4df835e579c 100644
--- a/web/tests/lib/index.cjs
+++ b/web/tests/lib/index.cjs
@@ -7,7 +7,6 @@ require("@date-fns/tz"); // To prevent @sinonjs/fake-timers from interfering wit
require("css.escape");
require("handlebars/runtime.js");
const {JSDOM} = require("jsdom");
-const _ = require("lodash");
const handlebars = require("./handlebars.cjs");
const namespace = require("./namespace.cjs");
@@ -34,11 +33,6 @@ Object.defineProperty(global, "navigator", {
require("@babel/register")({
extensions: [".cjs", ".cts", ".js", ".mjs", ".mts", ".ts"],
- only: [new RegExp("^" + _.escapeRegExp(path.resolve(__dirname, "../../src") + path.sep))],
- plugins: [
- ...(process.env.USING_INSTRUMENTED_CODE ? [["istanbul", {exclude: []}]] : []),
- ["@babel/plugin-transform-modules-commonjs", {lazy: () => true}],
- ],
root: path.resolve(__dirname, "../.."),
});