Skip to content

Commit 8874675

Browse files
committed
fix(profile-server): Add tsconfig path resolution to jest config
Because: - profile-server's jest config had no moduleNameMapper, so jest's node resolver couldn't find @fxa/shared/otel when loading lib/config.js during test-unit. The unit tests failed with "Cannot find module '@fxa/shared/otel' from 'lib/config.js'". This commit: - Adds pathsToModuleNameMapper from ts-jest so tsconfig paths (including @fxa/shared/*) resolve during jest runs, mirroring auth-server's config.
1 parent 66b57e2 commit 8874675

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

packages/fxa-profile-server/jest.config.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
import { pathsToModuleNameMapper } from 'ts-jest';
2+
import { compilerOptions } from '../../tsconfig.base.json';
3+
14
export default {
25
testEnvironment: 'node',
36
rootDir: '.',
4-
testMatch: [
5-
'<rootDir>/test/**/*.spec.ts',
6-
'<rootDir>/test/**/*.in.spec.ts',
7-
],
7+
testMatch: ['<rootDir>/test/**/*.spec.ts', '<rootDir>/test/**/*.in.spec.ts'],
88
moduleFileExtensions: ['ts', 'js', 'json'],
99
transform: {
10-
'^.+\\.tsx?$': ['ts-jest', { tsconfig: { isolatedModules: true, allowJs: false } }],
10+
'^.+\\.tsx?$': [
11+
'ts-jest',
12+
{ tsconfig: { isolatedModules: true, allowJs: false } },
13+
],
14+
},
15+
moduleNameMapper: {
16+
...pathsToModuleNameMapper(compilerOptions.paths, {
17+
prefix: '<rootDir>/../../',
18+
}),
1119
},
1220
testPathIgnorePatterns: ['/node_modules/'],
1321
testTimeout: 20000,

0 commit comments

Comments
 (0)