Skip to content

Commit

Permalink
Merge pull request #6983 from marmelab/fix-cherry-pick-jest-config
Browse files Browse the repository at this point in the history
Backport jest config from next
  • Loading branch information
fzaninotto authored Dec 13, 2021
2 parents bd409a5 + 0c9be76 commit 8729bc8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 21 deletions.
38 changes: 38 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require('path');
const fs = require('fs');

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;
}, {});

module.exports = {
globalSetup: './test-global-setup.js',
setupFilesAfterEnv: ['./test-setup.js'],
preset: 'ts-jest/presets/js-with-ts',
testPathIgnorePatterns: [
'/node_modules/',
'/lib/',
'/esm/',
'/examples/simple/',
],
transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|ts|tsx)$',
],
globals: {
'ts-jest': {
isolatedModules: true,
},
},
moduleNameMapper,
};
21 changes: 0 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,6 @@
"run-crm": "cd examples/crm && yarn -s start",
"build-crm": "cd examples/crm && yarn -s build"
},
"jest": {
"globalSetup": "./test-global-setup.js",
"setupFilesAfterEnv": [
"./test-setup.js"
],
"preset": "ts-jest/presets/js-with-ts",
"testPathIgnorePatterns": [
"/node_modules/",
"/lib/",
"/esm/",
"/examples/simple/"
],
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|ts|tsx)$"
],
"globals": {
"ts-jest": {
"isolatedModules": true
}
}
},
"devDependencies": {
"@types/jest": "^26.0.19",
"@types/react": "^17.0.20",
Expand Down

0 comments on commit 8729bc8

Please sign in to comment.