Skip to content

@testing-library/react run jest TypeError: (0 , _dom.configure) is not a function #1259

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

Closed
shashaMF opened this issue Dec 7, 2023 · 9 comments

Comments

@shashaMF
Copy link

shashaMF commented Dec 7, 2023

My problem is that I keep reporting this error while running Jest. If you know, please let me know. Thank you very much!
image
{
"@testing-library/dom": "9.0.0",
"@testing-library/jest-dom": "6.1.5",
"@testing-library/react": "12.1.3",
"@testing-library/user-event": "^12.1.10",
"react": "^17.0.1",
}

@agentdylan
Copy link

Similar report here, perhaps it can help?
#1055

Suggests it may be something to do with your jest moduleNameMapper config.

@MatanBobi
Copy link
Member

@shashaMF Can you please share a reproduction repo using https://testing-library.com/new-rtl? At the moment we can't help because a screenshot doesn't help us a lot.
Also, you probably don't need to install @testing-library/dom because it comes bundled in with @testing-library/react.

@shashaMF
Copy link
Author

shashaMF commented Dec 7, 2023

@shashaMF您能否使用https://testing-library.com/new-rtl分享复制存储库?目前我们无能为力,因为屏幕截图对我们没有多大帮助。 另外,您可能不需要安装,@testing-library/dom因为它与@testing-library/react.

Sorry, we are an internal data system and do not have an external address.

I see that the @ testing library/react code doesn't seem to recognize this way of writing:
image
I have never seen this function writing method before。
Can I uninstall @ testing library/dom。

@MatanBobi
Copy link
Member

Please share your jest config file and we'll try to help. It's written this way because the code is transpiled.

@shashaMF
Copy link
Author

shashaMF commented Dec 7, 2023

Please share your jest config file and we'll try to help. It's written this way because the code is transpiled.

image
My jest config is stored in package.json。

Could you please help me take a look? Thank you very much!

@agentdylan
Copy link

a wild guess... try changing this line
"config": "<rootDir>/src/config"
to
"^config$": "<rootDir>/src/config"

@shashaMF
Copy link
Author

shashaMF commented Dec 8, 2023

a wild guess... try changing this line "config": "<rootDir>/src/config" to "^config$": "<rootDir>/src/config"

Thank you, it is indeed the previous issue caused by config here. I have already removed it.

I want to ask you, Jest doesn't support the styled components notation. How did you solve it?
for example:
import { Wrapper } from './styled';
return ( <Wrapper> ..... </Wrapper>
This way, Jest will report an error
image
If you have time, please help me take a look. Thank you very much!

@MatanBobi
Copy link
Member

@shashaMF these kind of questions are better asked in stackoverflow or in our discord server.
I'm closing this since there's no problem in RTL.
Thank you.

@shashaMF
Copy link
Author

shashaMF commented Dec 11, 2023

@shashaMF these kind of questions are better asked in stackoverflow or in our discord server. I'm closing this since there's no problem in RTL. Thank you.

My problem has been solved. It was caused by a configuration in my Jest configuration. Thanks!

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