diff --git a/jest.config.js b/jest.config.js index a5db2edca..3c0d219f6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,30 +1,11 @@ +const jestConfig = require('@cerner/jest-config-terra'); + module.exports = { - collectCoverageFrom: [ - 'packages/**/src/*.js', - 'packages/**/src/*.jsx', - ], - globalSetup: './jestGlobalSetup.js', + ...jestConfig, setupFiles: [ - 'raf/polyfill', - './jestsetup.js', - ], - testMatch: [ - '**/jest/**/*.test.js?(x)', + './jest.enzymeSetup.js', ], - roots: [process.cwd()], snapshotSerializers: [ - './node_modules/enzyme-to-json/serializer', - ], - moduleDirectories: [ - 'aggregated-translations', - 'packages', - 'node_modules', + 'enzyme-to-json/serializer', ], - moduleNameMapper: { - '\\.(css|scss|svg)$': 'identity-obj-proxy', - }, - testURL: 'http://localhost', - transform: { - '^.+\\.(js|jsx)$': './jestBabelTransform', - }, }; diff --git a/jestsetup.js b/jest.enzymeSetup.js similarity index 75% rename from jestsetup.js rename to jest.enzymeSetup.js index 814358c73..7e58329da 100644 --- a/jestsetup.js +++ b/jest.enzymeSetup.js @@ -7,6 +7,3 @@ Enzyme.configure({ adapter: new Adapter() }); global.shallow = shallow; global.render = render; global.mount = mount; - -const htmlTag = document.getElementsByTagName('html')[0]; -htmlTag.setAttribute('dir', 'ltr'); diff --git a/jestBabelTransform.js b/jestBabelTransform.js deleted file mode 100644 index 01c3330ec..000000000 --- a/jestBabelTransform.js +++ /dev/null @@ -1,12 +0,0 @@ -const babelJest = require('babel-jest'); - -/** - * Jest uses babel.config.js to compile during the test runs. To correctly resolve babel's config root - * (because terra-clinical is a mono-repo), a custom transformer is needed for jest. - * See: https://babeljs.io/docs/en/config-files#jest - */ -const customTransformer = babelJest.createTransformer({ - rootMode: 'upward-optional', -}); - -module.exports = customTransformer; diff --git a/jestGlobalSetup.js b/jestGlobalSetup.js deleted file mode 100644 index 65f142f36..000000000 --- a/jestGlobalSetup.js +++ /dev/null @@ -1,5 +0,0 @@ -const aggregateTranslations = require('terra-aggregate-translations'); - -module.exports = () => { - aggregateTranslations(); -}; diff --git a/package.json b/package.json index 85ec81ed3..68143ff9b 100644 --- a/package.json +++ b/package.json @@ -51,11 +51,11 @@ "@babel/runtime": "^7.10.4", "@cerner/browserslist-config-terra": "^3.0.0", "@cerner/eslint-config-terra": "^5.0.0", + "@cerner/jest-config-terra": "^1.0.0", "@cerner/stylelint-config-terra": "^4.0.0", "@cerner/terra-cli": "^1.0.0", "@cerner/terra-open-source-scripts": "^1.0.1", "babel-eslint": "^10.1.0", - "babel-jest": "^24.8.0", "babel-loader": "^8.1.0", "babel-plugin-istanbul": "^6.0.0", "babel-plugin-minify-replace": "^0.5.0", @@ -82,8 +82,7 @@ "glob": "^7.1.1", "html-webpack-plugin": "^4.3.0", "husky": "^4.3.0", - "identity-obj-proxy": "^3.0.0", - "jest": "^24.8.0", + "jest": "^26.6.3", "jsdoc": "^3.6.4", "lerna": "^3.22.1", "link-parent-bin": "^1.0.0",