I'm currently integrating MUI v5 Pro components into my React library and then import those library components into my host app. I have set up the MUI license key in the .env
file of both the library and the host app, and I'm importing the necessary components like so:
import { LicenseInfo } from "@mui/x-license-pro";
LicenseInfo.setLicenseKey(import.meta.env.VITE_REACT_APP__MUI_KEY || "");
However, when I execute my Jest and React Library tests, I encounter a "missing license key" issue, even though the key is correctly set in the .env files.
console.error
*************************************************************
MUI: Missing license key.
The license key is missing. You might not be allowed to use `@mui/x-date-pickers-pro` which is part of MUI X Pro.
To solve the issue, you can check the free trial conditions: https://mui.com/r/x-license-trial.
If you are eligible no actions are required. If you are not eligible to the free trial, you need to purchase a license https://mui.com/r/x-get-license or stop using the software immediately.
*************************************************************
To complicate matters, not every developer on our team has access to this license key—primarily only front-end developers. Therefore, I want to ensure that the tests pass on every local machine, whether or not a developer has set the license key.
Is there a way to mock or bypass the license check only during Jest and React Library tests, ensuring they execute without requiring the key?