Skip to content

Commit

Permalink
feat(npm-scripts): add escape hatch for react 16 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bryceosterhaus committed Oct 18, 2023
1 parent a0879e9 commit 952adf3
Show file tree
Hide file tree
Showing 3 changed files with 434 additions and 28 deletions.
16 changes: 11 additions & 5 deletions projects/npm-tools/packages/npm-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
"@liferay/eslint-plugin": "1.4.0",
"@liferay/jest-junit-reporter": "1.2.0",
"@liferay/js-toolkit-core": "3.0.1",
"@testing-library/dom": "^8.11.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^3.4.2",
"@testing-library/user-event": "^4.2.4",
"@testing-library/dom": "^9.3.3",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.1",
"@testing-library/dom-8.11.1": "npm:@testing-library/[email protected]",
"@testing-library/jest-dom-4.2.4": "npm:@testing-library/[email protected]",
"@testing-library/react-12.1.2": "npm:@testing-library/[email protected]",
"@testing-library/react-hooks-3.4.2": "npm:@testing-library/[email protected]",
"@testing-library/user-event-4.2.4": "npm:@testing-library/[email protected]",
"@types/jest": "^26.0.14",
"babel-eslint": "^10.0.3",
"babel-jest": "^25.1.0",
Expand Down Expand Up @@ -64,6 +68,8 @@
"react": "*",
"react-dom": "*",
"react-test-renderer": "*",
"react-16": "npm:[email protected]",
"react-dom-16": "npm:[email protected]",
"regenerator-runtime": "0.13.7",
"resolve": "^1.14.2",
"rimraf": "^3.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

const path = require('path');

module.exports = {
const config = {
coverageDirectory: 'build/coverage',
modulePathIgnorePatterns: ['/__fixtures__/', '/build/', '/classes/'],
resolver: require.resolve('../jest/resolver.js'),
Expand All @@ -25,3 +25,28 @@ module.exports = {
},
transformIgnorePatterns: ['/node_modules/', '<rootDir>/.*\\.soy$'],
};

if (process.env.USE_REACT_16 === 'true') {
config.moduleNameMapper = {

// Testing dependencies

'^@testing-library/dom((\\/.*)?)$': '@testing-library/dom-8.11.1$1',
'^@testing-library/jest-dom((\\/.*)?)$':
'@testing-library/jest-dom-4.2.4$1',
'^@testing-library/react((\\/.*)?)$': '@testing-library/react-12.1.2$1',
'^@testing-library/react-hooks((\\/.*)?)$':
'@testing-library/react-hooks-3.4.2$1',
'^@testing-library/user-event((\\/.*)?)$':
'@testing-library/user-event-4.2.4$1',

// React Dependencies

'^react$': 'react-16',
'^react-dom$': 'react-dom-16',
'^react-dom/server$': 'react-dom-16/server',
'^react-dom/test-utils$': 'react-dom-16/test-utils',
};
}

module.exports = config;
Loading

0 comments on commit 952adf3

Please sign in to comment.