-
-
Notifications
You must be signed in to change notification settings - Fork 381
Expand file tree
/
Copy pathjest.config.base.js
More file actions
25 lines (22 loc) · 941 Bytes
/
jest.config.base.js
File metadata and controls
25 lines (22 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const path = require('path');
/**
* Base Jest configuration for the AsyncAPI Generator monorepo.
* This provides shared configuration, particularly for the nimma module mapping.
*
* @param {string} dirname - The __dirname of the package using this config
* @param {object} options - Additional configuration options
* @param {object} options.moduleNameMapper - Additional moduleNameMapper entries to merge
* @returns {object} Jest configuration object
*/
module.exports = (dirname, options = {}) => {
const repoRoot = __dirname;
const relativePath = path.relative(dirname, repoRoot);
const nodeModulesPath = relativePath ? `${relativePath}/node_modules` : 'node_modules';
return {
moduleNameMapper: {
'^nimma/legacy$': `<rootDir>/${nodeModulesPath}/nimma/dist/legacy/cjs/index.js`,
'^nimma/(.*)': `<rootDir>/${nodeModulesPath}/nimma/dist/cjs/$1`,
...(options.moduleNameMapper || {}),
},
};
};