Skip to content

Commit

Permalink
update packages, remove react-router 5 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaidman committed Dec 28, 2024
1 parent e243f07 commit fcc8a8f
Show file tree
Hide file tree
Showing 5 changed files with 1,872 additions and 2,003 deletions.
5 changes: 2 additions & 3 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const compact = require('lodash/compact');
module.exports = function(api) {
const isProd = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const isUseClassicJSX = process.env.USE_CLASSIC_JSX === 'true';

api.cache(false);

Expand All @@ -12,9 +11,9 @@ module.exports = function(api) {
modules: isTest ? 'commonjs' : false,
}],
['@babel/preset-react', {
runtime: isUseClassicJSX ? 'classic' : 'automatic',
runtime: 'automatic',
development: true,
importSource: isUseClassicJSX ? undefined : `${__dirname}`,
importSource: `${__dirname}`,
}],
];

Expand Down
6 changes: 3 additions & 3 deletions jestSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { errorOnConsoleOutput } from '@welldone-software/jest-console-handler';

const substringsToIgnore = [
'Selectors that return the entire state are almost certainly a mistake',
'Warning: ReactDOM.render is no longer supported in React 18',
'Warning: ReactDOM.render is no longer supported in React 19',
'Support for defaultProps will be removed from'
];
const regexToIgnore = new RegExp(`(${substringsToIgnore.join('|')})`);
Expand All @@ -13,6 +13,6 @@ global.flushConsoleOutput = errorOnConsoleOutput({ filterEntries: ({ args }) =>
} });

const React = require('react');
if (!React.version.startsWith('18')) {
throw new Error(`Wrong React version. Expected ^18, got ${React.version}`);
if (!React.version.startsWith('19')) {
throw new Error(`Wrong React version. Expected ^19, got ${React.version}`);
}
90 changes: 41 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@
],
"scripts": {
"start": "cross-env PORT=3003 NODE_ENV=development node demo/serve",
"start:classic": "cross-env USE_CLASSIC_JSX=true yarn start",
"build": "cross-env NODE_ENV=production rollup --config --bundleConfigAsCjs",
"test": "yarn test:automatic && yarn test:classic",
"test:automatic": "cross-env yarn _test",
"test:classic": "cross-env USE_CLASSIC_JSX=true yarn _test",
"_test": "jest --config=jest.config.js",
"test:watch": "yarn test:automatic --watch",
"test": "jest --config=jest.config.js",
"test:ci": "yarn test --coverage",
"lint": "eslint . --ext=js --max-warnings 0 --cache --cache-location .cache/eslint-cache",
"clear": "rimraf .cache dist demo/dist",
Expand All @@ -44,10 +39,8 @@
"postversion": "git push && git push --tags",
"cypress:open": "cypress open",
"cypress:run": "cypress run --browser chrome",
"_cypress:run:ci": "yarn cypress:run --record --group main",
"_cypress:run:ci:classic": "yarn cypress:run --record --group classic",
"cypress:ci": "start-server-and-test start http://localhost:3003 _cypress:run:ci",
"cypress:ci:classic": "start-server-and-test start:classic http://localhost:3003 _cypress:run:ci:classic"
"_cypress:ci": "yarn cypress:run --record --group main"
},
"comments": {
"how to": {
Expand All @@ -71,69 +64,68 @@
"lodash": "^4"
},
"peerDependencies": {
"react": "^18"
"react": "^19"
},
"resolutions": {
"source-map-fast": "npm:source-map@^0.8.0-beta.0",
"source-map": "^0.8.0-beta.0",
"string-width": "4.2.3"
},
"devDependencies": {
"@babel/cli": "^7.24.7",
"@babel/core": "^7.24.7",
"@babel/eslint-parser": "^7.24.7",
"@babel/plugin-transform-class-properties": "^7.24.7",
"@babel/preset-env": "^7.24.7",
"@babel/preset-react": "^7.24.7",
"@rollup/plugin-alias": "^5.1.0",
"@babel/cli": "^7.26.4",
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"@babel/plugin-transform-class-properties": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.26.3",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@testing-library/dom": "^10.1.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^16.0.0",
"@types/jest": "^29.5.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-redux": "^7.1.33",
"@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-replace": "^6.0.2",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.1.0",
"@types/jest": "^29.5.14",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@types/react-redux": "^7.1.34",
"@welldone-software/jest-console-handler": "^2.0.1",
"acorn-walk": "^8.3.2",
"astring": "^1.8.6",
"acorn-walk": "^8.3.4",
"astring": "^1.9.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^29.7.0",
"concurrently": "^8.2.2",
"concurrently": "^9.1.1",
"create-react-class": "^15.7.0",
"cross-env": "^7.0.3",
"cypress": "^13.11.0",
"eslint": "^8.57.0",
"eslint-plugin-cypress": "^3.3.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-react": "^7.34.2",
"express": "^4.19.2",
"cypress": "^13.17.0",
"eslint": "^9.17.0",
"eslint-plugin-cypress": "^4.1.0",
"eslint-plugin-jest": "^28.10.0",
"eslint-plugin-react": "^7.37.3",
"express": "^4.21.2",
"express-history-api-fallback": "^2.2.1",
"husky": "^9.0.11",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-cli": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"nollup": "^0.21.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-hot-loader": "^4.13.1",
"react-is": "^18.3.1",
"react-redux": "^9.1.2",
"react-router-dom": "^6.23.1",
"react-router-dom-5": "npm:react-router-dom@^5.3.4",
"react-is": "^19.0.0",
"react-redux": "^9.2.0",
"react-router-dom": "^7.1.1",
"redux": "^5.0.1",
"rimraf": "^5.0.7",
"rollup": "^4.18.0",
"rimraf": "^6.0.1",
"rollup": "^4.29.1",
"rollup-plugin-alias": "^2.2.0",
"rollup-plugin-commonjs-alternate": "^0.8.0",
"rollup-plugin-license": "^3.4.0",
"rollup-plugin-license": "^3.5.3",
"rollup-plugin-node-resolve": "^5.2.0",
"source-map": "npm:source-map@^0.8.0-beta.0",
"start-server-and-test": "^2.0.4",
"styled-components": "^6.1.11",
"typescript": "^5.4.5"
"start-server-and-test": "^2.0.9",
"styled-components": "^6.1.13",
"typescript": "^5.7.2"
}
}
80 changes: 1 addition & 79 deletions tests/librariesTests/react-router-dom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Routes as Routes6,
Route as Route6,
} from 'react-router-dom';
import { BrowserRouter as Router5, withRouter as withRouter5 } from 'react-router-dom-5';
import { connect, Provider } from 'react-redux';
import { cloneDeep } from 'lodash';
import * as rtl from '@testing-library/react';
Expand All @@ -27,84 +26,7 @@ afterEach(() => {
React.__REVERT_WHY_DID_YOU_RENDER__();
});

describe('react-router-dom-5', () => {
test('simple', () => {
const InnerComp = withRouter5(() => {
return <div>hi!</div>;
});

InnerComp.whyDidYouRender = true;

const Comp = () => (
<Router5>
<InnerComp/>
</Router5>
);

const { rerender } = rtl.render(<Comp/>);

rerender(<Comp/>);

expect(updateInfos).toHaveLength(1);
});

test('with redux', () => {
const initialState = { a: { b: 'c' } };

const rootReducer = (state, action) => {
if (action.type === 'differentState') {
return { a: { b: 'd' } };
}

if (action.type === 'deepEqlState') {
return cloneDeep(state);
}

return state;
};

const store = createStore(rootReducer, initialState);

const InnerFn = ({ a, setDeepEqlState }) => {
React.useLayoutEffect(() => {
setDeepEqlState();
}, []);

return <div>hi! {a.b}</div>;
};

InnerFn.whyDidYouRender = true;

const InnerComp = withRouter5(
connect(
state => ({ a: state.a }),
{ setDeepEqlState: () => ({ type: 'deepEqlState' }) }
)(InnerFn)
);

const Comp = () => (
<Provider store={store}>
<Router5>
<InnerComp/>
</Router5>
</Provider>
);

rtl.render(<Comp/>);

expect(updateInfos).toHaveLength(1);
expect(updateInfos[0].reason).toEqual({
propsDifferences: [
expect.objectContaining({ diffType: diffTypes.deepEquals }),
],
stateDifferences: false,
hookDifferences: false,
ownerDifferences: expect.anything(),
});
});
});

describe('react-router-dom-6', () => {
describe('react-router-dom', () => {
test('simple', () => {
const InnerComp = () => {
const location = useLocation6();
Expand Down
Loading

0 comments on commit fcc8a8f

Please sign in to comment.