From dabc37b79674bf62d1c2f11513ba24f8da0323e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Moiti=C3=A9?= Date: Wed, 3 Apr 2024 16:38:54 +0100 Subject: [PATCH] Strip out enzyme and react-test-renderer --- .eslintrc | 1 + jest.config.js | 11 +- package.json | 69 +- src/__tests__/App.test.js | 6 +- src/__tests__/__snapshots__/App.test.js.snap | 345 +- src/actions/auth.js | 1 - src/components/Checkbox.js | 2 +- src/components/CoachDaveSponsor.js | 2 +- src/components/FavouriteStarButton.js | 13 +- src/components/GlobalModals.js | 4 +- src/components/__tests__/BuyACoffee.test.js | 2 +- .../__tests__/CoachDaveSponsor.test.js | 1 - .../__tests__/FavouriteStarButton.test.js | 32 +- src/components/__tests__/GlobalModals.test.js | 54 +- src/components/__tests__/LicenceLevel.test.js | 51 +- src/components/__tests__/SortArrow.test.js | 12 +- .../__snapshots__/BuyACoffee.test.js.snap | 2 +- .../__snapshots__/Checkbox.test.js.snap | 3 + .../__snapshots__/DateSlider.test.js.snap | 34 +- .../FavouriteStarButton.test.js.snap | 31 +- .../__snapshots__/Filters.test.js.snap | 110 +- .../__snapshots__/GlobalModals.test.js.snap | 682 ++- .../__snapshots__/LicenceLevel.test.js.snap | 126 +- .../__snapshots__/Navbar.test.js.snap | 30 +- .../__snapshots__/RaceListing.test.js.snap | 16 +- .../__snapshots__/SortArrow.test.js.snap | 16 +- src/components/columns/Car.js | 1 + src/components/columns/LinkColumn.js | 1 + src/components/columns/__tests__/Car.test.js | 98 +- .../columns/__tests__/Class.test.js | 7 +- .../columns/__tests__/ColumnUtils.js | 13 + .../columns/__tests__/EndDate.test.js | 24 +- .../columns/__tests__/Fixed.test.js | 21 +- src/components/columns/__tests__/Id.test.js | 10 +- .../columns/__tests__/Licence.test.js | 8 +- .../columns/__tests__/LinkColumn.test.js | 17 +- .../columns/__tests__/NextRace.test.js | 14 +- .../columns/__tests__/Official.test.js | 24 +- .../columns/__tests__/RaceLength.test.js | 96 +- .../columns/__tests__/RaceTimes.test.js | 107 +- .../columns/__tests__/SeasonEnd.test.js | 22 +- .../columns/__tests__/Series.test.js | 75 +- .../columns/__tests__/StartDate.test.js | 22 +- .../columns/__tests__/Track.test.js | 80 +- src/components/columns/__tests__/Type.test.js | 18 +- .../__tests__/__snapshots__/Car.test.js.snap | 267 +- .../__snapshots__/Class.test.js.snap | 16 +- .../__snapshots__/Fixed.test.js.snap | 15 +- .../__snapshots__/Licence.test.js.snap | 18 +- .../__snapshots__/LinkColumn.test.js.snap | 5 +- .../__snapshots__/Official.test.js.snap | 15 +- .../__snapshots__/RaceTimes.test.js.snap | 219 +- .../__snapshots__/Series.test.js.snap | 557 +- .../__snapshots__/Track.test.js.snap | 11 +- src/components/icon/StarIcon.js | 2 +- src/components/icon/TickIcon.js | 2 +- .../icon/__tests__/LinkIcon.test.js | 6 +- .../icon/__tests__/RemoveIcon.test.js | 6 +- .../icon/__tests__/ShoppingCart.test.js | 6 +- .../icon/__tests__/StarIcon.test.js | 6 +- .../icon/__tests__/TickIcon.test.js | 6 +- .../__snapshots__/LinkIcon.test.js.snap | 2 +- .../__snapshots__/RemoveIcon.test.js.snap | 2 +- .../__snapshots__/ShoppingCart.test.js.snap | 2 +- .../__snapshots__/StarIcon.test.js.snap | 3 +- .../__snapshots__/TickIcon.test.js.snap | 3 +- src/components/modal/AboutModal.js | 2 +- src/components/modal/BaseModal.js | 69 +- src/components/modal/CarModal.js | 6 +- src/components/modal/ContentModal.js | 25 +- src/components/modal/FavouriteSeriesModal.js | 3 +- src/components/modal/LoginModal.js | 1 + src/components/modal/Modal.js | 3 +- src/components/modal/PurchaseGuideModal.js | 2 +- src/components/modal/SeriesModal.js | 1 + .../modal/__tests__/AboutModal.test.js | 22 +- .../modal/__tests__/CarModal.test.js | 33 +- .../modal/__tests__/ContentModal.test.js | 129 +- .../__tests__/FavouriteSeriesModal.test.js | 38 +- .../__tests__/ForgottenPasswordModal.test.js | 86 +- .../modal/__tests__/LoginModal.test.js | 131 +- src/components/modal/__tests__/Modal.test.js | 95 +- .../modal/__tests__/OptionsModal.test.js | 30 +- .../modal/__tests__/SeriesModal.test.js | 45 +- .../__snapshots__/AboutModal.test.js.snap | 338 +- .../__snapshots__/CarModal.test.js.snap | 220 +- .../__snapshots__/ContentModal.test.js.snap | 241 +- .../FavouriteSeriesModal.test.js.snap | 183 +- .../ForgottenPasswordModal.test.js.snap | 799 ++- .../__snapshots__/LoginModal.test.js.snap | 2331 ++++----- .../__snapshots__/Modal.test.js.snap | 172 +- .../__snapshots__/OptionsModal.test.js.snap | 582 +-- .../__snapshots__/SeriesModal.test.js.snap | 978 ++-- src/data/__tests__/availableColumns.test.js | 11 +- src/data/availableColumns.js | 9 +- src/data/offWeeks.js | 8 +- src/i18n.js | 2 +- src/reducers/__tests__/settings.test.js | 2 +- src/reducers/app.js | 2 +- src/reducers/settings.js | 6 +- test/setup.js | 11 +- yarn.lock | 4577 ++++++++--------- 102 files changed, 6752 insertions(+), 7924 deletions(-) create mode 100644 src/components/columns/__tests__/ColumnUtils.js diff --git a/.eslintrc b/.eslintrc index 3fc2057..1b83279 100644 --- a/.eslintrc +++ b/.eslintrc @@ -23,6 +23,7 @@ "ImportDeclaration": { "minProperties": 12, "multiline": true, "consistent": true }, "ExportDeclaration": { "minProperties": 12, "multiline": true, "consistent": true } }], + "react/no-invalid-html-attribute": [0], "react/jsx-props-no-spreading": [0], "quote-props": [0] }, diff --git a/jest.config.js b/jest.config.js index 8a393a4..0c2febe 100644 --- a/jest.config.js +++ b/jest.config.js @@ -45,7 +45,6 @@ module.exports = { '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '/__mocks__/fileMock.js', '\\.(css|scss)$': 'identity-obj-proxy', - "axios": "axios/dist/node/axios.cjs", }, // modulePathIgnorePatterns: [], // notify: false, @@ -65,19 +64,17 @@ module.exports = { // setupFiles: [], setupFilesAfterEnv: ['./__mocks__/client.js', 'jest-extended/all', '/test/setup.js'], // slowTestThreshold: 5, - snapshotSerializers: ['enzyme-to-json/serializer'], testEnvironment: 'jsdom', // testEnvironmentOptions: {}, // testLocationInResults: false, - // testMatch: [ - // "**/__tests__/**/*.[jt]s?(x)", - // "**/?(*.)+(spec|test).[tj]s?(x)" - // ], + testMatch: [ + // "**/__tests__/**/*.[jt]s?(x)", + "**/?(*.)+(spec|test).[tj]s?(x)" + ], testPathIgnorePatterns: [], // testRegex: [], // testResultsProcessor: undefined, // testRunner: "jasmine2", - testURL: 'http://localhost', // timers: "real", transform: { '^.+\\.(js|jsx|ts|tsx)$': '/node_modules/babel-jest', diff --git a/package.json b/package.json index 3bd4a3f..9e6afe4 100644 --- a/package.json +++ b/package.json @@ -38,12 +38,12 @@ "@babel/preset-flow": "^7.10.4", "@babel/preset-react": "^7.10.4", "@babel/register": "^7.10.5", - "@blueprintjs/core": "^3.31.0", + "@blueprintjs/core": "^5.10.1", "@formatjs/intl-datetimeformat": "^6.0.2", "@root/file-cookie-store": "^1.0.1", "autoprefixer": "^10.4.0", "axios": "^1.6.2", - "babel-loader": "^8.1.0", + "babel-loader": "^9.1.3", "babel-plugin-jest-hoist": "^29.0.2", "bootstrap-sass": "^3.3.6", "classnames": "^2.2.6", @@ -51,19 +51,19 @@ "core-js": "^3.26.1", "crypto-js": "^4.2.0", "css-loader": "^6.5.1", - "css-minimizer-webpack-plugin": "^4.0.0", + "css-minimizer-webpack-plugin": "^6.0.0", "css-modules-flow-types-loader": "^2.0.0", - "enzyme": "^3.11.0", "es5-shim": "^4.5.14", "file-loader": "^6.0.0", - "firebase": "^9.6.0", + "firebase": "^10.10.0", "flow-typed": "^3.2.1", "html-webpack-plugin": "^5.5.0", "html5shiv": "^3.7.3", - "http-cookie-agent": "^4.0.2", - "i18next": "^21.10.0", - "i18next-browser-languagedetector": "^6.0.1", + "http-cookie-agent": "^6.0.3", + "i18next": "^23.10.1", + "i18next-browser-languagedetector": "^7.2.1", "ignore-styles": "^5.0.1", + "jest-environment-jsdom": "^29.7.0", "lodash.debounce": "^4.0.8", "lodash.difference": "^4.5.0", "lodash.flatten": "^4.4.0", @@ -76,60 +76,59 @@ "mini-css-extract-plugin": "^2.4.5", "moment": "^2.29.2", "postcss": "^8.4.31", - "postcss-loader": "^7.0.1", + "postcss-loader": "^8.1.1", "prop-types": "^15.7.2", - "react": "^17.0.2", - "react-dom": "^17.0.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", "react-gtm-module": "^2.0.11", "react-hot-loader": "^4.12.21", - "react-i18next": "^11.18.6", - "react-modal": "^3.11.2", - "react-redux": "^7.2.1", - "redux": "^4.0.5", + "react-i18next": "14.1.0", + "react-redux": "9.1.0", + "redux": "5.0.1", "redux-localstorage": "^1.0.0-rc5", "redux-localstorage-filter": "^0.1.1", "redux-thunk": "^2.3.0", "respond.js": "^1.4.2", "sass": "^1.44.0", - "sass-loader": "^13.0.2", + "sass-loader": "^14.1.1", "style-loader": "^3.3.1", "terser-webpack-plugin": "^5.2.5", "tough-cookie": "^4.1.3", "url-loader": "^4.1.0", "util.promisify": "^1.1.1", - "webpack": "^5.65.0", - "webpack-cli": "^4.9.1" + "webpack": "^5.91.0", + "webpack-cli": "^5.1.4" }, "devDependencies": { - "@jest/globals": "^27.4.2", - "@testing-library/jest-dom": "^6.1.5", - "@testing-library/react": "^12.1.2", - "@wojtekmaj/enzyme-adapter-react-17": "^0.6.5", + "@jest/globals": "^29.7.0", + "@testing-library/dom": "^9.3.4", + "@testing-library/jest-dom": "^6.4.2", + "@testing-library/react": "^14.2.2", + "@testing-library/user-event": "^14.5.2", "babel-eslint": "^10.1.0", - "enzyme-to-json": "^3.5.0", - "eslint": "^7.10.0", - "eslint-config-airbnb": "^18.2.0", - "eslint-plugin-flowtype": "^5.2.0", + "babel-jest": "^29.7.0", + "eslint": "8.57.0", + "eslint-config-airbnb": "19.0.4", + "eslint-plugin-flowtype": "8.0.3", "eslint-plugin-import": "^2.22.1", - "eslint-plugin-jest": "^24.1.0", + "eslint-plugin-jest": "27.9.0", "eslint-plugin-jsx-a11y": "^6.3.1", "eslint-plugin-react": "^7.21.3", "eslint-plugin-react-hooks": "^4.1.2", - "flow-bin": "^0.173.0", + "flow-bin": "0.233.0", "flush-promises": "^1.0.2", "identity-obj-proxy": "^3.0.0", - "jest": "^27.4.3", + "jest": "^29.7.0", "jest-css-modules-transform": "^4.0.1", - "jest-extended": "^1.2.0", - "jsdom": "^20.0.2", + "jest-extended": "^4.0.2", + "jsdom": "^24.0.0", "mockdate": "^3.0.2", - "react-test-renderer": "^17.0.2", + "react-test-renderer": "^18.2.0", "redux-logger": "^3.0.6", "redux-mock-store": "^1.5.4", - "regenerator-runtime": "^0.13.7", - "snapshot-diff": "^0.9.0", + "snapshot-diff": "^0.10.0", "webpack-bundle-analyzer": "^4.9.1", - "webpack-dev-server": "^4.6.0" + "webpack-dev-server": "^5.0.4" }, "resolutions": { "@root/file-cookie-store/**/tough-cookie": "^4.1.3" diff --git a/src/__tests__/App.test.js b/src/__tests__/App.test.js index 7c0f40d..d8d5ead 100644 --- a/src/__tests__/App.test.js +++ b/src/__tests__/App.test.js @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, test } from '@jest/globals'; import moment from 'moment'; import React from 'react'; -import renderer from 'react-test-renderer'; +import { render } from '@testing-library/react'; import { Provider } from 'react-redux'; import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; @@ -53,9 +53,9 @@ describe('components/App', () => { test('renders correctly', () => { const store = mockStore(defaultStore); - const component = renderer.create(); + const { container } = render(); - expect(component.toJSON()).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); expect(store.getActions()[0].type).toEqual(SIGNED_IN); expect(store.getActions()[0].user).not.toBeDefined(); diff --git a/src/__tests__/__snapshots__/App.test.js.snap b/src/__tests__/__snapshots__/App.test.js.snap index f821de1..e4e17bd 100644 --- a/src/__tests__/__snapshots__/App.test.js.snap +++ b/src/__tests__/__snapshots__/App.test.js.snap @@ -3,42 +3,40 @@ exports[`components/App renders correctly 1`] = `

Sponsored

Looking for iRacing Setups?

Grab a setup from Coach Dave Academy, developed by professional sim racers and engineers.

Browse Setups

@@ -307,90 +281,81 @@ exports[`components/App renders correctly 1`] = ` Filters

Type