Skip to content

Commit

Permalink
Ensure all packages are aliased for Jest
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis CI authored and WiXSL committed Dec 12, 2021
1 parent e1afd5c commit c9f59e9
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');
const fs = require('fs');

module.exports = {
globalSetup: './test-global-setup.js',
Expand All @@ -18,12 +19,20 @@ module.exports = {
isolatedModules: true,
},
},
moduleNameMapper: {
'^ra-core(.*)$': path.join(__dirname, './packages/ra-core/src$1'),
'^ra-test(.*)$': path.join(__dirname, './packages/ra-test/src$1'),
'^ra-ui-materialui(.*)$': path.join(
__dirname,
'./packages/ra-ui-materialui/src$1'
),
},
moduleNameMapper,
};

const packages = fs.readdirSync(path.resolve(__dirname, './packages'));
const moduleNameMapper = packages.reduce((mapper, dirName) => {
const package = require(path.resolve(
__dirname,
'./packages',
dirName,
'package.json'
));
mapper[`^${package.name}(.*)$`] = path.join(
__dirname,
`./packages/${dirName}/src$1`
);
return mapper;
}, {});

0 comments on commit c9f59e9

Please sign in to comment.