Skip to content

Commit 8651a9f

Browse files
Merge pull request #1221 from bryceosterhaus/react16test
feat(npm-scripts): allow for testing in react-16 exclusively
2 parents 40fa93e + 1ce8115 commit 8651a9f

File tree

3 files changed

+485
-16
lines changed

3 files changed

+485
-16
lines changed

Diff for: projects/npm-tools/packages/npm-scripts/package.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717
"@liferay/eslint-plugin": "1.4.0",
1818
"@liferay/jest-junit-reporter": "1.2.0",
1919
"@liferay/js-toolkit-core": "3.0.1",
20-
"@testing-library/dom": "^8.11.1",
21-
"@testing-library/jest-dom": "^4.2.4",
22-
"@testing-library/react": "^12.1.2",
23-
"@testing-library/react-hooks": "^3.4.2",
24-
"@testing-library/user-event": "^4.2.4",
20+
"@testing-library/dom": "^9.3.3",
21+
"@testing-library/jest-dom": "^6.1.4",
22+
"@testing-library/react": "^14.0.0",
23+
"@testing-library/user-event": "^14.5.1",
24+
"@testing-library/dom-8.11.1": "npm:@testing-library/[email protected]",
25+
"@testing-library/jest-dom-4.2.4": "npm:@testing-library/[email protected]",
26+
"@testing-library/react-12.1.2": "npm:@testing-library/[email protected]",
27+
"@testing-library/react-hooks-3.4.2": "npm:@testing-library/[email protected]",
28+
"@testing-library/user-event-4.2.4": "npm:@testing-library/[email protected]",
2529
"@types/jest": "^26.0.14",
2630
"@types/react-dom": "17.0.3",
2731
"@types/vfile-message": "2.0.0",
@@ -50,6 +54,8 @@
5054
"prettier": "^2.1.2",
5155
"react": "*",
5256
"react-dom": "*",
57+
"react-16": "npm:[email protected]",
58+
"react-dom-16": "npm:[email protected]",
5359
"react-test-renderer": "*",
5460
"resolve": "^1.14.2",
5561
"sass": "^1.29.0",

Diff for: projects/npm-tools/packages/npm-scripts/src/config/jest.config.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
const path = require('path');
77

8-
module.exports = {
8+
const config = {
99
coverageDirectory: 'build/coverage',
1010
modulePathIgnorePatterns: ['/__fixtures__/', '/build/', '/classes/'],
1111
resolver: require.resolve('../jest/resolver.js'),
@@ -24,3 +24,28 @@ module.exports = {
2424
},
2525
transformIgnorePatterns: ['/node_modules/'],
2626
};
27+
28+
if (process.env.USE_REACT_16 === 'true') {
29+
config.moduleNameMapper = {
30+
31+
// Testing dependencies
32+
33+
'^@testing-library/dom((\\/.*)?)$': '@testing-library/dom-8.11.1$1',
34+
'^@testing-library/jest-dom((\\/.*)?)$':
35+
'@testing-library/jest-dom-4.2.4$1',
36+
'^@testing-library/react((\\/.*)?)$': '@testing-library/react-12.1.2$1',
37+
'^@testing-library/react-hooks((\\/.*)?)$':
38+
'@testing-library/react-hooks-3.4.2$1',
39+
'^@testing-library/user-event((\\/.*)?)$':
40+
'@testing-library/user-event-4.2.4$1',
41+
42+
// React Dependencies
43+
44+
'^react$': 'react-16',
45+
'^react-dom$': 'react-dom-16',
46+
'^react-dom/server$': 'react-dom-16/server',
47+
'^react-dom/test-utils$': 'react-dom-16/test-utils',
48+
};
49+
}
50+
51+
module.exports = config;

0 commit comments

Comments
 (0)