Skip to content

[MOO-1924] Fix react native configs#136

Merged
LEGIO-SEXTA-FERRATA merged 7 commits intomendix:masterfrom
vadymv-mendix:moo/MOO-1924-fix-react-native-configs
Sep 19, 2025
Merged

[MOO-1924] Fix react native configs#136
LEGIO-SEXTA-FERRATA merged 7 commits intomendix:masterfrom
vadymv-mendix:moo/MOO-1924-fix-react-native-configs

Conversation

@vadymv-mendix
Copy link
Contributor

Checklist

  • Contains unit tests ❌
  • Contains breaking changes ✅
  • Compatible with: MX 11
  • 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?

Update Jest configs for Native test to use recommended preset, as well as remove Enzyme support.

Relevant changes

  • removed Enzyme support from Jest config for Native tests
  • use the same React Native version as Native Widgets project does

Copy link
Collaborator

@weirdwater weirdwater left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Considering that enzyme has been removed from the default jest configuration, do the templates in the generator need updating as well?

@vadymv-mendix
Copy link
Contributor Author

Thanks for the PR. Considering that enzyme has been removed from the default jest configuration, do the templates in the generator need updating as well?

Hmm, didn't think about those. You're right, I'll have to do the changes there as well, also will need to add the RN testing library to the list of dependencies.

@weirdwater
Copy link
Collaborator

When I generate a new widget with tests using this branch I get the following error when running npm test

Running MX Widgets Tools script test:unit:native...
 FAIL  src/components/__tests__/HelloWorld.spec.tsx
  ● Test suite failed to run

    Incorrect version of "react-test-renderer" detected. Expected "18.3.1", but found "18.2.0".

    Fix it by running:
    npm install -D [email protected]

      1 | import { createElement } from "react";
    > 2 | import { render } from "@testing-library/react-native";
        | ^
      3 | import { Platform } from "react-native";
      4 |
      5 | import { HelloWorld, HelloWorldProps } from "../HelloWorld";

      at Object.ensurePeerDeps (../node_modules/@testing-library/react-native/src/helpers/ensure-peer-deps.ts:36:3)
      at Object.require (../node_modules/@testing-library/react-native/src/index.ts:1:1)
      at Object.<anonymous> (components/__tests__/HelloWorld.spec.tsx:2:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        7.378 s

My steps:

# Prepare tools
cd ~/Projects/widgets-tools
pnpm install
cd ./packages/pluggable-widgets-tools
pnpm pack

# Generate widget
cd ~/Mendix/testApp/myPluggableWidgets
~/Projects/widgets-tools/packages/generator-widget/bin.js NativeTestApp
cd nativeTestApp
rm -rf node_modules
npm install ~/Projects/widgets-tools/packages/pluggable-widgets-tools/mendix-pluggable-widgets-tools-10.21.4.tgz
npm install

npm test

@weirdwater
Copy link
Collaborator

Looking into it a bit deeper I believe we need to do the following to make the tests runnable after generating a widget:

Generator Widget

  • Remove react and react-native from the devDependencies
  • Revert the react-native override

Pluggable Widgets Tools

  • Update the react-test-renderer dependency to 18.3.1

The version mismatch seems to be coming from the @cfaester/enzyme-adapter-react-18 and @testing-library/react-native dependencies. Alternatively we could remove the react-test-renderer dependency and let it be managed by the earlier mentioned dependencies.

@vadymv-mendix vadymv-mendix force-pushed the moo/MOO-1924-fix-react-native-configs branch from 05df46f to 37281e6 Compare September 9, 2025 15:33
@vadymv-mendix
Copy link
Contributor Author

@weirdwater can you please let me know if it works for you after my last update?

@weirdwater
Copy link
Collaborator

Yes, using these latest changes I can generate a widget and run the tests. I will ask another team member to approve as well.

@weirdwater
Copy link
Collaborator

One note: We will need a changelog entry for the generator-widget.

@vadymv-mendix
Copy link
Contributor Author

@weirdwater I've updated the changelog so please re-review

@LEGIO-SEXTA-FERRATA LEGIO-SEXTA-FERRATA merged commit 10933ff into mendix:master Sep 19, 2025
7 checks passed
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.

5 participants