testing-library / react-testing-library

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.

Home Page:https://testing-library.com/react

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

shashaMF opened this issue · comments

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",
}

Similar report here, perhaps it can help?
#1055

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

@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您能否使用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。

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

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!

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

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!

@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 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!