sindresorhus/normalize-url

Error using react testing library

Closed this issue · 7 comments

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?

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

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

@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/.*)",
	],

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

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

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.