react-hooks-testing-library icon indicating copy to clipboard operation
react-hooks-testing-library copied to clipboard

Critical dependency: the request of a dependency is an expression

Open UladzKha opened this issue 3 years ago • 1 comments

After installation and some unit test for my custom hook I receive this error message after run application. I've tried to reinstall all packages, remove node_modules ... didn't work. Does anybody havve an idea how it can be fixed ?

./node_modules/@testing-library/react-hooks/lib/pure.js 39:4-17 Critical dependency: the request of a dependency is an expression

UladzKha avatar Aug 22 '22 11:08 UladzKha

Please provide a reproduction of your issue.

joshuaellis avatar Sep 07 '22 07:09 joshuaellis

Same issue here.

volkanunsal avatar Dec 05 '22 22:12 volkanunsal

Are you trying to bundle your code (webpack, rollup, whatever)? I suspect the error is coming from this line where we try to load the renderer from a variable, but the bundler doesn't know how tor resolve that.

If this is the case, the solution is to change your import to a specific renderer, e.g. '@testing-library/react-hooks -> @testing-library/react-hooks/dom (assuming you are testing for a browser environment but alternative options can be found here).

mpeyper avatar Dec 05 '22 23:12 mpeyper

This worked. Thanks for the reply.

volkanunsal avatar Dec 05 '22 23:12 volkanunsal

Closing due to inactivity from the original poster

joshuaellis avatar Dec 06 '22 08:12 joshuaellis