Skip to content

Conversation

@LEGIO-SEXTA-FERRATA
Copy link
Contributor

@LEGIO-SEXTA-FERRATA LEGIO-SEXTA-FERRATA commented Nov 28, 2025

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
  • 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

@alihcsumer alihcsumer force-pushed the WTF-2273-remove-enzyme branch 2 times, most recently from 33ed431 to eaab3ca Compare December 3, 2025 15:45
@alihcsumer alihcsumer force-pushed the WTF-2273-remove-enzyme branch from ba40f08 to 5c6c594 Compare December 4, 2025 14:45
@alihcsumer alihcsumer force-pushed the WTF-2273-remove-enzyme branch from 3dc1e92 to 6ef55e0 Compare December 10, 2025 14:58
"test": "pluggable-widgets-tools test:unit:web --no-cache --ci && npm run test:e2e",
"test:unit": "pluggable-widgets-tools test:unit:web --coverage",
"test": "pluggable-widgets-tools test:unit:web && npm run test:e2e",
"test:unit": "pluggable-widgets-tools test:unit:web",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running unit tests on a generated widget from the command line I get the following error:

AIL  src/components/__tests__/HelloWorldSample.spec.tsx
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

"@babel/plugin-transform-class-properties": "^7.25.9",
"@babel/plugin-transform-private-methods": "^7.25.9",
"@babel/plugin-transform-react-jsx": "^7.25.9",
"@babel/preset-env": "^7.26.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we update versions on generator and pluggable widgets tools ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants