Jest
Create jest.config.ts in your project root:
import type { Config } from 'jest';import baseConfig from '@presencelearning/frontend-config/jest';
export default { ...baseConfig, // Customize module name mappings for your project moduleNameMapper: { ...baseConfig.moduleNameMapper, '@my-alias/(.*)': '<rootDir>/src/my-path/$1', },} satisfies Config;The base config sets setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], so you must create that file — an empty one is fine to start. Without it the first run fails with a module-not-found error. The shipped MSW template at msw-templates/jest-global-mocks.ts is a good starting point; copy it to jest.setup.ts and fill in the server import it stubs out. It pulls in jest-location-mock and whatwg-fetch, which you install yourself.
Features
Section titled “Features”jest-preset-angularconfiguration (the CJS preset, not ESM)jest-fixed-jsdomtest environment, withcustomExportConditions: ['']so MSW resolves correctly- MSW (Mock Service Worker) compatible
- Coverage reporting to
test-results/unit-coverage, collected fromsrc/app/**andsrc/lib-components/** lodash-es→lodashandchart.jsmodule mappings- Ignores
<rootDir>/projectsand<rootDir>/ui-tests
Migration from existing Jest config
Section titled “Migration from existing Jest config”- Backup your
jest.config.js - Create new
jest.config.tsimporting the base config - Copy custom
moduleNameMapperentries - Remove redundant settings (already in base config)
Troubleshooting
Section titled “Troubleshooting”Jest can’t resolve path aliases
Section titled “Jest can’t resolve path aliases”Update moduleNameMapper in your jest.config.ts to match your tsconfig.json paths.