diff --git a/jest.config.ut.js b/jest.config.ut.js index 993072aad9..6846f72151 100644 --- a/jest.config.ut.js +++ b/jest.config.ut.js @@ -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, `/${relativePath}/${path}`]) + Object.entries(pathsToModuleNameMapper(compilerOptions.paths || {})) + .map(([moduleName, paths]) => [moduleName, (Array.isArray(paths) ? paths : [paths]).map(path => `/${relativePath}/${path}`)]) ); return { preset: 'ts-jest', diff --git a/packages/@o3r/testing/schematics/ng-add/templates/workspace/jest.config.ut.js.template b/packages/@o3r/testing/schematics/ng-add/templates/workspace/jest.config.ut.js.template index 5e7f2c741e..3a5c0cfa7a 100644 --- a/packages/@o3r/testing/schematics/ng-add/templates/workspace/jest.config.ut.js.template +++ b/packages/@o3r/testing/schematics/ng-add/templates/workspace/jest.config.ut.js.template @@ -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] = `/${relativePath}/${path}`; - return acc; - }, {}); + const moduleNameMapper = Object.fromEntries( + Object.entries(pathsToModuleNameMapper(compilerOptions.paths || {})) + .map(([moduleName, paths]) => [moduleName, (Array.isArray(paths) ? paths : [paths]).map(path => `/${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 {