-
Notifications
You must be signed in to change notification settings - Fork 19
[WTF-2485]: Remove enzyme from widget generator in preparation of React 19 #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
...mplates/pluggable/web/emptyTemplateTs/src/components/__tests__/HelloWorldSample.spec.tsx.ejs
Show resolved
Hide resolved
33ed431 to
eaab3ca
Compare
eaab3ca to
e413267
Compare
be91f9e to
ba40f08
Compare
ba40f08 to
5c6c594
Compare
| name: "copyright", | ||
| message: "Add a copyright", | ||
| default: "© Mendix Technology BV 2022. All rights reserved.", | ||
| default: "© Mendix Technology BV 2025. All rights reserved.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just make this dynamic at this point? I.e. © Mendix Technology BV ${new Date().getFullYear()}. All rights reserved. Otherwise we will be updating it again in four weeks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it would be great if we could implement this as a Typescript file. It would need to be part of the src directory and the mx-scripts file should import it from the dist directory.
| } | ||
| } | ||
| } | ||
| } catch (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see an error logged here. Even if it is just for us to debug.
| /from\s+['"]enzyme['"]/.test(content) || | ||
| /require\s*\(\s*['"]enzyme['"]\s*\)/.test(content) || | ||
| /import\s+.*\s+from\s+['"]enzyme['"]/.test(content) || | ||
| /shallow|mount|render/.test(content) && /enzyme/.test(content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we describe this as a single, or less regexes? This seems to be performing a lot of scans of the same text
| scanDirectory(fullPath); | ||
| } else if ( | ||
| stat.isFile() && | ||
| (entry.endsWith(".js") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can limit this to just spec files or files in test directories.
| return `jest --projects "${join(toolsRoot, "test-config/jest.config.js")}"`; | ||
| case "test:unit:native": | ||
| return `jest --projects "${join(toolsRoot, "test-config/jest.native.config.js")}"`; | ||
| case "test:unit:web:enzyme-free": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this down to the removed commands -- or fall back to the test:unit:web command
| }, | ||
| "resolutions": { | ||
| "react": "^18.2.0", | ||
| "react-dom": "18.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to add react-dom here?
| "lint": "pluggable-widgets-tools lint", | ||
| "lint:fix": "pluggable-widgets-tools lint:fix", | ||
| "test": "pluggable-widgets-tools test:unit:web --no-cache --ci && npm run test:e2e", | ||
| "test:unit": "pluggable-widgets-tools test:unit:web --coverage", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we forget to remove this with an earlier story?
|
|
||
| ### Breaking changes | ||
|
|
||
| - We removed Enzyme testing library and associated dependencies from pluggable-widgets-tools. Tests using Enzyme should be updated to use React Testing Library. See the [migration guide](https://testing-library.com/docs/react-testing-library/migrate-from-enzyme) for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also announce to update the command used from test:unit:web:enzyme to test:unit:web
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can look into implementing this as a custom eslint rule. The benefits would be:
- Developers get the warnings/errors right in the editor
- ESlint provides api's for analyzing the AST, which would allow us to specifically find methods imported from enzyme libraries.
- If a developer chooses, they can surpress that specific rule and continue using enzyme.
3dc1e92 to
6ef55e0
Compare
Checklist
[XX-000]: description)? ✅This PR contains
What is the purpose of this PR?
This PR prepares the Yeoman widget generator for replacing the Enzyme for testing in favor of RTL, the React Testing Library.
Relevant changes
What should be covered while testing?
REMAINING:
npm installis run