sindresorhus / normalize-url

Normalize a URL
MIT License
837 stars 123 forks source link

Error using react testing library #166

Closed italosantana closed 2 years ago

italosantana commented 2 years ago

image

Using normalize-url latest version, and I am trying to render a component with react testing library and show this error.

In the error it says it's to fix "Must use import to load ES Module", and the babel-jest I'm using is already doing that. But it does not work!

Does anyone have an idea what it could be?

italosantana commented 2 years ago

@sindresorhus Do you have any idea what it could be?

sindresorhus commented 2 years ago

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

beshur commented 1 year ago

@italosantana, did you manage to implement the advice suggested by Sindre?

italosantana commented 1 year ago

@italosantana, did you manage to implement the advice suggested by Sindre?

yes, @beshur! I was having a problem with jest. Putting in transforIgnorePatterns and it's worked for me.

transformIgnorePatterns: [
        "node_modules/(?!normalize-url/.*)",
    ],
beshur commented 1 year ago

Thanks for reply, @italosantana. That didn't help me. Anything else maybe?

italosantana commented 1 year ago

@beshur Show me more details about your error, please.

beshur commented 1 year ago

In the end I stuck with the mocked libraries, and require is not defined in jest config even after replacing jest.mock with jest.unstable_mockModule.