Skip to content
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

"Error: act(...) is not supported in production builds of React" with jest.config.mjs generated by crafty v1.24.0 #2281

Closed
denuko opened this issue Feb 26, 2024 · 4 comments

Comments

@denuko
Copy link

denuko commented Feb 26, 2024

Hello! After upgrading to crafty v1.24.0 and generating files with crafty ide, the following issue is happening specifically with jest.config.mjs:

After generating and using the jest.config.mjs in IntelliJ integrated test run, the following error occurs

Error: act(...) is not supported in production builds of React.
 
    at Object.<anonymous>.exports.unstable_act (/home/dkasidia/workspace/securities-retail-paid-prices-plugin/server-war/src/main/frontend/node_modules/react/cjs/react.production.min.js:23:393)

I reproduced that with crafty v1.24.0 and the newly generated jest.config.mjs. The test run was working fine with previous jest.config.js (generated by older crafty version).

I tried to add NODE_ENV=test in the configuration so that it's appended to the jest command, but it was not effective.
MicrosoftTeams-image (27)

I did some console.log in jest.config.mjs to check NODE_ENV. Initially it's test, then changes to production after initialize()
MicrosoftTeams-image (28)

Could you please look into that? Thanks!

@onigoetz
Copy link
Member

Hi, thanks for the report

Crafty needs to set the environment variable for builds, and indeed, tests have different needs than builds.

I hardcoded

// Crafty configures its own environment for builds
// tests have different needs
process.env.NODE_ENV = "test";

right after initialize
I will release this soon but you can add it to your file in the meantime

@onigoetz
Copy link
Member

Released Released in https://github.com/swissquote/crafty/releases/tag/v1.25.0

@denuko
Copy link
Author

denuko commented Feb 28, 2024

I tried the new release and it works great! Thanks a lot!

@onigoetz
Copy link
Member

awesome, happy it works :)

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

No branches or pull requests

2 participants