-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
Jest tests fail for missing module #4380
Comments
This shouldn't be happening. Is there any chance you are able to create a minimal sandbox reproduction to help us debug this? |
Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information. |
Hi, I'm getting the same failure when using Here's the minimal reproducer that I was able to come up with:
This fails on a different error. Error detail
I'm able to solve this one by updating diff --git a/package.json b/package.json
index 99b979b..e42bfda 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +15,7 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
- "test": "react-scripts test",
+ "test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!@toolpad)\"",
"eject": "react-scripts eject"
},
"eslintConfig": { Then, Error details
I can solve this one, too, with:
And after that, Error details
I tried |
A quick look. The code is imported like this:
but then, Does Jest support package.json |
Can reproduce this locally. I see similar issues when I try with the upcoming base-ui packages. Will investigate if there's a way to remedy in jest config. |
Looks like I can get it to work by adding extra jest config in the package.json: // package.json
"jest": {
"transformIgnorePatterns": [
"node_modules/(?!(@toolpad/)).*\\..*$"
],
"moduleNameMapper": {
"@toolpad/utils/(.*)": "@toolpad/utils/dist/$1"
}
}, But I wouldn't recommend it. Be warned if you use this: This will guaranteed break some day on a patch dependency upgrade. IIUC upcoming base UI module layout will also rely on the exports field to locate its sources. I assume it will also be broken the same way in CRA/jest. cc @mui/base-ui |
Steps to reproduce
Link to live example: (required)
Steps:
<AppProvider/>
and<DashboardLayout/>
in codeCurrent behavior
Adding
<AppProvider/>
and<DashboardLayout/>
components cause local tests to fail.For failing tests we see either of these two messages:
or
Expected behavior
Tests do not fail
Context
Our team is trying to leverage
AppProvider
andDashboardLayout
components to build our Navigation Bar component. We are using: @testing-library/jest-dom version 5.17. Upon importing and using these components in our code, we immediately see our tests fail.As more context, our
node_modules/@toolpad/
Does not haveuseNotifications/
. It seems our tests are failing because of this, although in nowhere in the code or tests we are using that hook.Your environment
npx @mui/envinfo
Search keywords: useNotifications, Jest, AppProvider, DashboardLayout
The text was updated successfully, but these errors were encountered: