Skip to content

Commit 7ec333b

Browse files
authored
[WTF-2485]: Remove enzyme from widget generator in preparation of React 19 (#156)
## Checklist - Contains unit tests ✅ - Contains breaking changes ✅ - Compatible with: MX 1️⃣1️⃣ - Did you update version and changelog? ❌ - PR title properly formatted (`[XX-000]: description`)? ✅ ## This PR contains - [ ] Bug fix - [ ] Feature - [ ] Refactor - [ ] Documentation - [x] Other (describe) ## 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 - The generator for web package.json is adjusted to remove enzyme as a dependency - The react-dom dependency is added to resolutions and overrides as RTL required it - The scaffolded unit tests when the user chooses the unit test option are adjusted for RTL - Generator tests are adjusted - A bonus fix for updating the copyright year is included. ## What should be covered while testing? - Both the options with unit test and e2e should be tested - The generator tests must be green - The default tests that arrive with a scaffolded widget should be green ## **REMAINING**: - Check native - Check e2e tests - PWT Workflow Actions seems to be failing for the PR - One issue is that, the scaffolded widget is not able to run the unit tests before `npm install` is run - Check if we can get rid of the non-enzyme config in PWT - Add a check in PWT to detect and warn on enzyme tests (grepping on enzyme imports will do probably) - Mention as breaking change in release notes - Check docs
2 parents beec6ae + bc9fe30 commit 7ec333b

File tree

43 files changed

+378
-635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+378
-635
lines changed

packages/generator-widget/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Changed
10+
11+
- We migrated the generated unit tests to use React Testing Library instead of enzyme.
12+
13+
- We changed the copyright prompt to prefill the current year.
14+
915
## [10.24.0] - 2025-09-24
1016

1117
### Changed

packages/generator-widget/generators/app/lib/prompttexts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function promptWidgetProperties(mxProjectDir, widgetName) {
3131
type: "input",
3232
name: "copyright",
3333
message: "Add a copyright",
34-
default: "© Mendix Technology BV 2022. All rights reserved.",
34+
default: `© Mendix Technology BV ${new Date().getFullYear()}. All rights reserved.`,
3535
store: true
3636
},
3737
{

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_native.json-js-unit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"output": "./dist/testresults/TESTS-Jest.xml"
2828
},
2929
"devDependencies": {
30-
"@mendix/pluggable-widgets-tools": "^10.15.0"
30+
"@mendix/pluggable-widgets-tools": "^11.3.1"
3131
},
3232
"dependencies": {
3333

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_native.json-js.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"release": "pluggable-widgets-tools release:native"
2323
},
2424
"devDependencies": {
25-
"@mendix/pluggable-widgets-tools": "^10.15.0"
25+
"@mendix/pluggable-widgets-tools": "^11.3.1"
2626
},
2727
"dependencies": {
2828

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_native.json-ts-unit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"output": "./dist/testresults/TESTS-Jest.xml"
2828
},
2929
"devDependencies": {
30-
"@mendix/pluggable-widgets-tools": "^10.15.0",
30+
"@mendix/pluggable-widgets-tools": "^11.3.1",
3131
"@types/big.js": "^6.0.2",
3232
"@types/jest": "^29.0.0"
3333
},

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_native.json-ts.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"release": "pluggable-widgets-tools release:native"
2323
},
2424
"devDependencies": {
25-
"@mendix/pluggable-widgets-tools": "^10.15.0",
25+
"@mendix/pluggable-widgets-tools": "^11.3.1",
2626
"@types/big.js": "^6.0.2"
2727
},
2828
"dependencies": {

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_web.json-js-e2e.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,20 @@
2626
"release": "pluggable-widgets-tools release:web"
2727
},
2828
"devDependencies": {
29-
"@mendix/pluggable-widgets-tools": "^10.15.0",
29+
"@mendix/pluggable-widgets-tools": "^11.3.1",
3030
"cypress": "^10.10.0"
3131
},
3232
"dependencies": {
3333
"classnames": "^2.2.6"
3434
},
3535
"resolutions": {
3636
"react": "^18.2.0",
37+
"react-dom": "18.2.0",
3738
"react-native": "0.72.7"
3839
},
3940
"overrides": {
4041
"react": "^18.2.0",
42+
"react-dom": "18.2.0",
4143
"react-native": "0.72.7"
4244
}
4345
}

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_web.json-js-unit-e2e.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,27 @@
2121
"build": "pluggable-widgets-tools build:web",
2222
"lint": "pluggable-widgets-tools lint",
2323
"lint:fix": "pluggable-widgets-tools lint:fix",
24-
"test": "pluggable-widgets-tools test:unit:web --no-cache --ci && npm run test:e2e",
25-
"test:unit": "pluggable-widgets-tools test:unit:web --coverage",
24+
"test": "pluggable-widgets-tools test:unit:web && npm run test:e2e",
25+
"test:unit": "pluggable-widgets-tools test:unit:web",
2626
"test:e2e": "npx cypress open --browser chrome --e2e",
2727
"prerelease": "npm run lint",
2828
"release": "pluggable-widgets-tools release:web"
2929
},
3030
"devDependencies": {
31-
"@mendix/pluggable-widgets-tools": "^10.15.0",
31+
"@mendix/pluggable-widgets-tools": "^11.3.1",
3232
"cypress": "^10.10.0"
3333
},
3434
"dependencies": {
3535
"classnames": "^2.2.6"
3636
},
3737
"resolutions": {
3838
"react": "^18.2.0",
39+
"react-dom": "18.2.0",
3940
"react-native": "0.72.7"
4041
},
4142
"overrides": {
4243
"react": "^18.2.0",
44+
"react-dom": "18.2.0",
4345
"react-native": "0.72.7"
4446
}
4547
}

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_web.json-js-unit.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,25 @@
2121
"build": "pluggable-widgets-tools build:web",
2222
"lint": "pluggable-widgets-tools lint",
2323
"lint:fix": "pluggable-widgets-tools lint:fix",
24-
"test": "pluggable-widgets-tools test:unit:web --no-cache --ci",
25-
"test:unit": "pluggable-widgets-tools test:unit:web --coverage",
24+
"test": "pluggable-widgets-tools test:unit:web",
25+
"test:unit": "pluggable-widgets-tools test:unit:web",
2626
"prerelease": "npm run lint",
2727
"release": "pluggable-widgets-tools release:web"
2828
},
2929
"devDependencies": {
30-
"@mendix/pluggable-widgets-tools": "^10.15.0"
30+
"@mendix/pluggable-widgets-tools": "^11.3.1"
3131
},
3232
"dependencies": {
3333
"classnames": "^2.2.6"
3434
},
3535
"resolutions": {
3636
"react": "^18.2.0",
37+
"react-dom": "18.2.0",
3738
"react-native": "0.72.7"
3839
},
3940
"overrides": {
4041
"react": "^18.2.0",
42+
"react-dom": "18.2.0",
4143
"react-native": "0.72.7"
4244
}
4345
}

packages/generator-widget/generators/app/templates/packages/__tests__/outputs/package_web.json-js.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@
2525
"release": "pluggable-widgets-tools release:web"
2626
},
2727
"devDependencies": {
28-
"@mendix/pluggable-widgets-tools": "^10.15.0"
28+
"@mendix/pluggable-widgets-tools": "^11.3.1"
2929
},
3030
"dependencies": {
3131
"classnames": "^2.2.6"
3232
},
3333
"resolutions": {
3434
"react": "^18.2.0",
35+
"react-dom": "18.2.0",
3536
"react-native": "0.72.7"
3637
},
3738
"overrides": {
3839
"react": "^18.2.0",
40+
"react-dom": "18.2.0",
3941
"react-native": "0.72.7"
4042
}
4143
}

0 commit comments

Comments
 (0)