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

Jest 28.0.0 and jest-environment-jsdom fails to import use-debounce in tests #132

Closed
Glup3 opened this issue May 3, 2022 · 6 comments
Closed

Comments

@Glup3
Copy link

Glup3 commented May 3, 2022

Describe the bug
Importing the package does not work since the Jest 28.0.0 update in combination with jest-environment-jsdom.

To Reproduce

  1. update jest to 28.0.0
  2. use jest-environment-jsdom (28.0.0)
  3. create a test that uses use-debounce
  4. run the test

Expected behavior
The test should run successfully.

use-debounce version: 8.0.0

Additional Information
This problem is also in other packages (described in their docs) https://jestjs.io/docs/upgrading-to-jest28#packagejson-exports
Here is the analysis of the problem and their workaround, which works:
microsoft/accessibility-insights-web#5421 (comment)
microsoft/accessibility-insights-web@9ad4e61

@sibelius
Copy link

sibelius commented May 5, 2022

this is breaking our server side rendering with webpack as well

@sibelius
Copy link

sibelius commented May 5, 2022

removing

"exports": {
    ".": {
      "browser": "./dist/index.module.js",
      "umd": "./dist/index.umd.js",
      "import": "./dist/index.mjs",
      "require": "./dist/index.js",
      "default": "./dist/index.module.js"
    }
  },

from package.json solved the problem

@sibelius
Copy link

sibelius commented May 5, 2022

patch-package for now

diff --git a/package.json b/package.json
index 43ccad5..1cb6bf2 100644
--- a/node_modules/use-debounce/package.json
+++ b/node_modules/use-debounce/package.json
@@ -7,15 +7,6 @@
   "module": "dist/index.module.js",
   "esmodule": "dist/index.modern.js",
   "umd:main": "dist/index.umd.js",
-  "exports": {
-    ".": {
-      "browser": "./dist/index.module.js",
-      "umd": "./dist/index.umd.js",
-      "import": "./dist/index.mjs",
-      "require": "./dist/index.js",
-      "default": "./dist/index.module.js"
-    }
-  },
   "sideEffects": false,
   "scripts": {
     "size": "yarn build-only && size-limit",

@xnimorz
Copy link
Owner

xnimorz commented May 5, 2022

Hey @Glup3 and @sibelius !

Sorry, for the long response, and huge thanks to both of you!

I updated the exports section dd377cb and tested on the local project with jest@28 and jest-environment-jsdom, so the new version should work properly.

I've published [email protected], you can update to this version.

Let me know if everything is okay for you

@sibelius
Copy link

sibelius commented May 6, 2022

it is working well for me, tks

@xnimorz
Copy link
Owner

xnimorz commented May 6, 2022

Great, thanks for the info

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

No branches or pull requests

3 participants