Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: jest.config.ut.js not processing array in tsconfig paths correctly #2605

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jest.config.ut.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports.getJestProjectConfig = (rootDir, isAngularSetup, options) => {
).config;
const relativePath = relative(rootDir, options?.baseTsconfig ? __dirname(options.baseTsconfig) : __dirname);
const moduleNameMapper = Object.fromEntries(
Object.entries(pathsToModuleNameMapper(compilerOptions.paths))
.map(([moduleName, path]) => [moduleName, `<rootDir>/${relativePath}/${path}`])
Object.entries(pathsToModuleNameMapper(compilerOptions.paths || {}))
.map(([moduleName, paths]) => [moduleName, (Array.isArray(paths) ? paths : [paths]).map(path => `<rootDir>/${relativePath}/${path}`)])
);
return {
preset: 'ts-jest',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const baseTsconfigPath = resolve(__dirname, './tsconfig.json');
module.exports.getJestProjectConfig = (rootDir, isAngularSetup) => {
const { compilerOptions } = ts.parseConfigFileTextToJson(baseTsconfigPath, readFileSync(baseTsconfigPath, { encoding: 'utf-8' })).config;
const relativePath = relative(rootDir, __dirname);
const moduleNameMapper = Object.entries(pathsToModuleNameMapper(compilerOptions.paths || {})).reduce((acc, [moduleName, path]) => {
acc[moduleName] = `<rootDir>/${relativePath}/${path}`;
return acc;
}, {});
const moduleNameMapper = Object.fromEntries(
Object.entries(pathsToModuleNameMapper(compilerOptions.paths || {}))
.map(([moduleName, paths]) => [moduleName, (Array.isArray(paths) ? paths : [paths]).map(path => `<rootDir>/${relativePath}/${path}`)])
);
moduleNameMapper['^@o3r/testing/core$'] = [require.resolve('@o3r/testing/core/angular')];
moduleNameMapper['^@o3r/testing/core/(.*)'] = [join(require.resolve('@o3r/testing/core/angular'), '$1')];
return {
Expand Down
Loading