You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ms...@apache.org on 2025/06/06 13:21:46 UTC

(superset) branch msyavuz/chore/react-18 created (now 4faf3d6083)

This is an automated email from the ASF dual-hosted git repository.

msyavuz pushed a change to branch msyavuz/chore/react-18
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 4faf3d6083 refactor(enzyme): remove enzyme

This branch includes the following new commits:

     new 4faf3d6083 refactor(enzyme): remove enzyme

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: refactor(enzyme): remove enzyme

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

msyavuz pushed a commit to branch msyavuz/chore/react-18
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 4faf3d60837c0e3e773ea0a91476c86839d61ae8
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Fri Jun 6 16:21:23 2025 +0300

    refactor(enzyme): remove enzyme
---
 superset-frontend/jest.config.js                        |  2 +-
 superset-frontend/package.json                          |  4 ----
 superset-frontend/spec/helpers/shim.tsx                 |  5 -----
 .../spec/helpers/{theming.ts => theming.tsx}            | 17 ++++++++++-------
 .../spec/helpers/waitForComponentToPaint.ts             | 17 +++--------------
 .../src/SqlLab/components/TabbedSqlEditors/index.tsx    |  2 +-
 6 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/superset-frontend/jest.config.js b/superset-frontend/jest.config.js
index 634221c242..f9aec71caf 100644
--- a/superset-frontend/jest.config.js
+++ b/superset-frontend/jest.config.js
@@ -55,7 +55,7 @@ module.exports = {
   ],
   coverageReporters: ['lcov', 'json-summary', 'html', 'text'],
   transformIgnorePatterns: [
-    'node_modules/(?!d3-(interpolate|color|time)|remark-gfm|markdown-table|micromark-*.|decode-named-character-reference|character-entities|mdast-util-*.|unist-util-*.|ccount|escape-string-regexp|nanoid|@rjsf/*.|sinon|echarts|zrender|fetch-mock|pretty-ms|parse-ms|ol|@babel/runtime|@emotion|cheerio|cheerio/lib|parse5|dom-serializer|entities|htmlparser2|rehype-sanitize|hast-util-sanitize|unified|unist-.*|hast-.*|rehype-.*|remark-.*|mdast-.*|micromark-.*|parse-entities|property-information| [...]
+    'node_modules/(?!d3-(interpolate|color|time)|remark-gfm|markdown-table|micromark-*.|decode-named-character-reference|character-entities|mdast-util-*.|unist-util-*.|ccount|escape-string-regexp|nanoid|@rjsf/*.|sinon|echarts|zrender|fetch-mock|pretty-ms|parse-ms|ol|@babel/runtime|@emotion|cheerio|cheerio/lib|parse5|dom-serializer|entities|htmlparser2|rehype-sanitize|hast-util-sanitize|unified|unist-.*|hast-.*|rehype-.*|remark-.*|mdast-.*|micromark-.*|parse-entities|property-information| [...]
   ],
   preset: 'ts-jest',
   transform: {
diff --git a/superset-frontend/package.json b/superset-frontend/package.json
index 9c9422e794..ad8a68d444 100644
--- a/superset-frontend/package.json
+++ b/superset-frontend/package.json
@@ -261,7 +261,6 @@
     "@testing-library/user-event": "^12.8.3",
     "@types/classnames": "^2.2.10",
     "@types/dom-to-image": "^2.6.7",
-    "@types/enzyme": "^3.10.18",
     "@types/fetch-mock": "^7.3.2",
     "@types/jest": "^29.5.12",
     "@types/jquery": "^3.5.8",
@@ -291,7 +290,6 @@
     "@types/yargs": "12 - 18",
     "@typescript-eslint/eslint-plugin": "^5.62.0",
     "@typescript-eslint/parser": "^5.62.0",
-    "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
     "babel-jest": "^29.7.0",
     "babel-loader": "^10.0.0",
     "babel-plugin-dynamic-import-node": "^2.3.3",
@@ -303,8 +301,6 @@
     "cross-env": "^7.0.3",
     "css-loader": "^7.1.2",
     "css-minimizer-webpack-plugin": "^7.0.2",
-    "enzyme": "^3.11.0",
-    "enzyme-matchers": "^7.1.2",
     "eslint": "^8.56.0",
     "eslint-config-airbnb": "^19.0.4",
     "eslint-config-prettier": "^7.2.0",
diff --git a/superset-frontend/spec/helpers/shim.tsx b/superset-frontend/spec/helpers/shim.tsx
index af5ea84681..c8c19a5661 100644
--- a/superset-frontend/spec/helpers/shim.tsx
+++ b/superset-frontend/spec/helpers/shim.tsx
@@ -20,10 +20,7 @@ import { AriaAttributes } from 'react';
 import 'core-js/stable';
 import 'regenerator-runtime/runtime';
 import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
-import 'enzyme-matchers';
 import jQuery from 'jquery';
-import Enzyme from 'enzyme';
-import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
 // https://jestjs.io/docs/jest-object#jestmockmodulename-factory-options
 // in order to mock modules in test case, so avoid absolute import module
 import { configure as configureTranslation } from '../../packages/superset-ui-core/src/translation';
@@ -33,8 +30,6 @@ import { ResizeObserver } from './ResizeObserver';
 import setupSupersetClient from './setupSupersetClient';
 import CacheStorage from './CacheStorage';
 
-Enzyme.configure({ adapter: new Adapter() });
-
 const exposedProperties = ['window', 'navigator', 'document'];
 
 const { defaultView } = document;
diff --git a/superset-frontend/spec/helpers/theming.ts b/superset-frontend/spec/helpers/theming.tsx
similarity index 82%
rename from superset-frontend/spec/helpers/theming.ts
rename to superset-frontend/spec/helpers/theming.tsx
index d24126b8d1..03a014ab4b 100644
--- a/superset-frontend/spec/helpers/theming.ts
+++ b/superset-frontend/spec/helpers/theming.tsx
@@ -16,9 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { mount as enzymeMount } from 'enzyme';
 // eslint-disable-next-line no-restricted-imports
 import { supersetTheme } from '@superset-ui/core';
+import { render } from 'spec/helpers/testing-library';
 import { ReactElement } from 'react';
 import { ProviderWrapper } from './ProviderWrapper';
 
@@ -33,12 +33,15 @@ export function styledMount(
   component: ReactElement,
   options: optionsType = {},
 ): any {
-  return enzymeMount(component, {
+  return render(component, {
+    wrapper: ({ children }) => (
+      <ProviderWrapper
+        theme={supersetTheme}
+        {...options?.wrappingComponentProps}
+      >
+        {children}
+      </ProviderWrapper>
+    ),
     ...options,
-    wrappingComponent: ProviderWrapper,
-    wrappingComponentProps: {
-      theme: supersetTheme,
-      ...options?.wrappingComponentProps,
-    },
   });
 }
diff --git a/superset-frontend/spec/helpers/waitForComponentToPaint.ts b/superset-frontend/spec/helpers/waitForComponentToPaint.ts
index 2e57a80b41..bc307d3ea3 100644
--- a/superset-frontend/spec/helpers/waitForComponentToPaint.ts
+++ b/superset-frontend/spec/helpers/waitForComponentToPaint.ts
@@ -16,19 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { ReactWrapper } from 'enzyme';
-import { act } from 'react-dom/test-utils';
+import { waitFor } from 'spec/helpers/testing-library';
 
-// taken from: https://github.com/enzymejs/enzyme/issues/2073
-// There is currently and issue with enzyme and react-16's hooks
-// that results in a race condition between tests and react hook updates.
-// This function ensures tests run after all react updates are done.
-export default async function waitForComponentToPaint<P = {}>(
-  wrapper: ReactWrapper<P>,
-  amount = 0,
-) {
-  await act(async () => {
-    await new Promise(resolve => setTimeout(resolve, amount));
-    wrapper.update();
-  });
+export default async function waitForComponentToPaint(amount = 0) {
+  await waitFor(() => new Promise(resolve => setTimeout(resolve, amount)));
 }
diff --git a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx
index ef931af873..be39b8beac 100644
--- a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx
+++ b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx
@@ -230,7 +230,7 @@ class TabbedSqlEditors extends PureComponent<TabbedSqlEditorsProps> {
       <EditableTabs.TabPane
         key={qe.id}
         tab={<SqlEditorTabHeader queryEditor={qe} />}
-        // for tests - key prop isn't handled by enzyme well bcs it's a react keyword
+        // for tests - key prop isn't handled by testing-library well bcs it's a react keyword
         data-key={qe.id}
       >
         <SqlEditor