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

Cannot find module 'expect' from 'extend-expect.js' #34

Closed
azdanov opened this issue Apr 2, 2018 · 5 comments
Closed

Cannot find module 'expect' from 'extend-expect.js' #34

azdanov opened this issue Apr 2, 2018 · 5 comments

Comments

@azdanov
Copy link

azdanov commented Apr 2, 2018

This only happens when I include import 'react-testing-library/extend-expect'. Otherwise react-testing-library works well. What might be the cause of this problem?

I am using latest create-react-app.

Error:

 FAIL  src/App.test.js
   Test suite failed to run

    Cannot find module 'expect' from 'extend-expect.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
      at Object.<anonymous> (node_modules/react-testing-library/dist/extend-expect.js:7:15)

Failing test:

it('should have a title', () => {
  const { getByText } = render(<App />);
  const text = 'Welcome to React';
  expect(getByText(text)).toBeInTheDOM();
});

Passing test:

it('should have a title', () => {
  const { getByText } = render(<App />);
  const text = 'Welcome to React';
  expect(getByText(text).innerHTML).toBe(text);
});
@kentcdodds
Copy link
Member

Ah, I know what's up. We don't need to import expect at all. It's a global. I'll fix it now.

@kentcdodds
Copy link
Member

A fix should be published in a few minutes.

@azdanov
Copy link
Author

azdanov commented Apr 2, 2018

Thanks, works as expected now!

julienw pushed a commit to julienw/react-testing-library that referenced this issue Dec 20, 2018
…y#34)

* poc for getting/querying by title

* updated docs, tests, simplified implementation
@interglobalmedia
Copy link

Hi Kent, love your library. Am also taking the course. .toBeInTheDOM() is still in the REAME.md and was a bit confusing when I went in to find out what I could use in a test. However, I only found out that it was not the thing to use when I received a warning after running npm test. Perhaps, however, it might be nice if .toBeInTheDOM() was replaced with .toBeIntheDocument() in the README.md? Thanks!

@kentcdodds
Copy link
Member

Thank you for the reminder @interglobalmedia! Would you like to provide that fix?

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