Skip to content

Commit 0c7dc90

Browse files
refactor: streamline moduleNameMapper usage in jest.config.js
1 parent 60ab0c5 commit 0c7dc90

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

jest.config.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
const aliasMapper = {
2+
logger: "<rootDir>/js/logger.js"
3+
};
4+
15
const config = {
26
verbose: true,
37
testTimeout: 20000,
@@ -6,21 +10,21 @@ const config = {
610
{
711
displayName: "unit",
812
globalSetup: "<rootDir>/tests/unit/helpers/global-setup.js",
9-
moduleNameMapper: {
10-
logger: "<rootDir>/js/logger.js"
11-
},
13+
moduleNameMapper: aliasMapper,
1214
testMatch: ["**/tests/unit/**/*.[jt]s?(x)"],
1315
testPathIgnorePatterns: ["<rootDir>/tests/unit/mocks", "<rootDir>/tests/unit/helpers"]
1416
},
1517
{
1618
displayName: "electron",
1719
testMatch: ["**/tests/electron/**/*.[jt]s?(x)"],
20+
moduleNameMapper: aliasMapper,
1821
testPathIgnorePatterns: ["<rootDir>/tests/electron/helpers"]
1922
},
2023
{
2124
displayName: "e2e",
2225
testMatch: ["**/tests/e2e/**/*.[jt]s?(x)"],
2326
modulePaths: ["<rootDir>/js/"],
27+
moduleNameMapper: aliasMapper,
2428
testPathIgnorePatterns: ["<rootDir>/tests/e2e/helpers", "<rootDir>/tests/e2e/mocks"]
2529
}
2630
],

js/check_config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
// Ensure internal require aliases (e.g., "logger") resolve when this file is run as a standalone script
2+
require("./alias-resolver");
3+
14
const path = require("node:path");
25
const fs = require("node:fs");
36
const { styleText } = require("node:util");
47
const Ajv = require("ajv");
58
const globals = require("globals");
69
const { Linter } = require("eslint");
10+
const Log = require("logger");
711

812
const rootPath = path.resolve(`${__dirname}/../`);
9-
const Log = require(`${rootPath}/js/logger.js`);
1013
const Utils = require(`${rootPath}/js/utils.js`);
1114

1215
const linter = new Linter({ configType: "flat" });

0 commit comments

Comments
 (0)