Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
feat: use moduleDirectories option in jest to avoid moduleNameMapper …
Browse files Browse the repository at this point in the history
…pain
  • Loading branch information
fargito committed Mar 28, 2022
1 parent 14d6980 commit 98b6122
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
5 changes: 4 additions & 1 deletion backend/core/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { jestConfig } from '@swarmion-starter/configuration';

export default jestConfig;
export default {
...jestConfig,
moduleDirectories: ['node_modules', '<rootDir>'],
};
5 changes: 4 additions & 1 deletion backend/forum/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { jestConfig } from '@swarmion-starter/configuration';

export default jestConfig;
export default {
...jestConfig,
moduleDirectories: ['node_modules', '<rootDir>'],
};
5 changes: 4 additions & 1 deletion backend/users/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { jestConfig } from '@swarmion-starter/configuration';

export default jestConfig;
export default {
...jestConfig,
moduleDirectories: ['node_modules', '<rootDir>'],
};
10 changes: 0 additions & 10 deletions frontend/app/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ const config: InitialOptionsTsJest = {
...jestConfig,
testEnvironment: 'jsdom',
moduleNameMapper: {
'^__fixtures__(/(.*)|)$': '<rootDir>/src/__fixtures__/$1',
'^components(/(.*)|)$': '<rootDir>/src/components/$1',
'^hooks(/(.*)|)$': '<rootDir>/src/hooks/$1',
'^pages(/(.*)|)$': '<rootDir>/src/pages/$1',
'^services(/(.*)|)$': '<rootDir>/src/services/$1',
'^AppRoutes$': '<rootDir>/src/AppRoutes',
'^store(/(.*)|)$': '<rootDir>/src/store/$1',
'^testUtils(/(.*)|)$': '<rootDir>/src/testUtils/$1',
'^theme(/(.*)|)$': '<rootDir>/src/theme/$1',
'^translations(/(.*)|)$': '<rootDir>/src/translations/$1',
'@react-hookz/web/esnext': '@react-hookz/web',
'^.*\\.svg$': '<rootDir>/src/__mocks__/svgrMock.ts',
},
Expand Down
3 changes: 0 additions & 3 deletions frontend/shared/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { jestConfig } from '@swarmion-starter/configuration';
const config: Config.InitialOptions = {
...jestConfig,
testEnvironment: 'jsdom',
moduleNameMapper: {
'^components(/(.*)|)$': '<rootDir>/src/components/$1',
},
setupFiles: ['dotenv-flow/config'],
setupFilesAfterEnv: ['<rootDir>/jest.setupAfterEnv.ts'],
};
Expand Down
1 change: 1 addition & 0 deletions packages/configuration/src/config/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config: InitialOptionsTsJest = {
coverageReporters: ['json', ['lcov', { projectRoot: './' }]],
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
modulePathIgnorePatterns: ['/dist/'],
moduleDirectories: ['node_modules', '<rootDir>/src'],
};

export default config;
5 changes: 4 additions & 1 deletion tools/generators/service/files/jest.config.ts__tmpl__
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { jestConfig } from '@<%= workspaceName %>/configuration';

export default jestConfig;
export default {
...jestConfig,
moduleDirectories: ['node_modules', '<rootDir>'],
};

0 comments on commit 98b6122

Please sign in to comment.