Skip to content
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

[4.1.3] Cannot find module 'jest-dom/extend-expect' #138

Closed
ryota-murakami opened this issue Jul 18, 2018 · 15 comments
Closed

[4.1.3] Cannot find module 'jest-dom/extend-expect' #138

ryota-murakami opened this issue Jul 18, 2018 · 15 comments

Comments

@ryota-murakami
Copy link
Contributor

  • react-testing-library version: 4.1.4
  • react version: 16.4.1
  • node version: 9.11.1
  • npm (or yarn) version: yarn 1.3.2

Relevant code or config:

// occurring error this line
import 'jest-dom/extend-expect'

entire test code
https://github.com/ryota-murakami/redux-boilerplate-less-architecture/blob/master/src/pages/github/index.test.js

What you did:

What happened:

Test Broke with Cannot find module 'jest-dom/extend-expect'

Reproduction:

I don't know why is that happening because there is no jest-dom change [https://github.com/kentcdodds/react-testing-library/compare/v4.1.2...v4.1.3](between v4.1.2
v4.1.3).

something of dom-testing-liblary?
thanks😀

@kentcdodds
Copy link
Member

You have to install jest-dom manually.
Good luck!

@ryota-murakami
Copy link
Contributor Author

Thanks, it works😀

julienw pushed a commit to julienw/react-testing-library that referenced this issue Dec 20, 2018
@jamiek-acl
Copy link

I am having the same problem - what does "You have to install jest-dom manually." mean? Thanks.

@alexkrolick
Copy link
Collaborator

It's a separate package

npm install -D jest-dom
# or yarn
yarn add --dev jest-dom

@jamiek-acl
Copy link

I've done that; its in my package.json (^3.1.3)

@nec286
Copy link

nec286 commented Sep 15, 2019

yarn add -D @testing-library/jest-dom

@s-Hale
Copy link

s-Hale commented Sep 17, 2019

any update on this? There's still a lot of mixed info out there - jest-dom is now packaged in, toBeInTheDocument must come from jest-dom, jest-dom is deprecated, it's @testing-library/jest-dom now, you need to import it, you don't need to import it... All the set-up guides are out of date.

If I import {toBeInTheDocument} from '@testing-library/jest-dom' then I'm told Cannot find module '@testing-library/jest-dom' and if I don't then TypeError: expect(...).toBeInTheDocument is not a function

@eps1lon
Copy link
Member

eps1lon commented Sep 17, 2019

@s-Hale Did you install @testing-library/jest-dom? Either via https://github.com/testing-library/jest-dom#installation or yarn add -D @testing-library/jest-dom

@nharrisanalyst
Copy link

I am still getting this error nothing is fixing it
OK I just got this error

jest-dom has moved to @testing-library/jest-dom. Please uninstall jest-dom and install @testing-library/jest-dom instead, or use an older version of jest-dom. Learn more about this change here: testing-library/dom-testing-library#260 Thanks!

@stevenYouhana
Copy link

replace
import "jest-dom/jest-dom/extend-expect";
with
import "@testing-library/jest-dom/extend-expect";

@MadhavanPalani
Copy link

Step 1: Uninstall jest-dom(deprecated one)
npm uninstall jest-dom

Step 2:Install testing-library/jest-dom
npm i @testing-library/jest-dom

Step 3:Replace
import "jest-dom/jest-dom/extend-expect";
with
import "@testing-library/jest-dom/extend-expect";

Thanks @stevenYouhana

@proustibat
Copy link

If some of you still have the problem: I fixed it by using

import '@testing-library/jest-dom';

instead of jest-dom/jest-dom/extend-expect

This is the recommanded usage by the official documentation

@Ronald-Cifuentes
Copy link

https://github.com/testing-library/jest-dom#installation

FYI
Currently the official documentation recommend us to use

// In tsconfig.json
"include": [ "./jest-setup.ts"],

@davidauza-engineer
Copy link

"./jest-setup.ts"

That worked for me.

Thank you, @Ronald-Cifuentes

@nickserv nickserv pinned this issue Sep 11, 2023
@nickserv nickserv unpinned this issue Sep 11, 2023
@mdjahidhasan009
Copy link

If some of you still have the problem: I fixed it by using

import '@testing-library/jest-dom';

instead of jest-dom/jest-dom/extend-expect

This is the recommanded usage by the official documentation

Thanks it works for me.

ceithir added a commit to ceithir/sakkaku that referenced this issue Oct 31, 2023
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