TypeError: createJWKSMock is not a function
mariusailisoaie opened this issue · 2 comments
Hello!
I'm using mock-jwks and nock to mock the auth0 authorization in a Node.js project but after switching to Jest 27 and enabling ES modules I get this error "TypeError: createJWKSMock is not a function". The tests were working fine before I enabled ES modules in Jest. Also, I'm not doing any kind of code transformation/compilation.
This is a screenshot with the error I'm getting:
Can anyone help me with this please?
Thank you and have a good day!
I assume you are doing the import wrong. But from this little information I cannot do much for you. I would console.log
the imported variable to see what it actually is. At the moment it looks like createJWKSMock
is an object, not a function, maybe the function is under the key default
in the object? This seems to be an issue with module interoperability rather than this package. If you need further help, please create a demo repo in github with a minimal example to reproduce your issue. Until then I will close as wontfix
.
Hi again @levino ! Your comment helped me solve the problem. This is how I imported the package in the project: import createJWKSMock from 'mock-jwks'
. You were right, createJWKSMock
is an object and I had to use the default
key in order to get the function (createJWKSMock(url)
-> createJWKSMock.default(url)
). Thank you for the package. It is very useful.
All the best and have a nice day/evening!