Jest test: Cannot find module '../Link.react' from 'Link.react.js'

Viewed 575

I am trying to setup jest test following https://jestjs.io/docs/en/tutorial-react I have installed the jest related dependencies, created __test__/link.react.test.js and Link.react.js. Following is my structure: enter image description here

However, it has problem for the test as following. But My structure and two files are exactly same as the tutorial.

FAIL  __tests__/link.react.test.js
  ● Test suite failed to run

    Cannot find module '../Link.react' from 'Link.react.js'

       5 | 
       6 | import React from 'react';
    >  7 | import Link from '../Link.react';
         | ^
       8 | import renderer from 'react-test-renderer';
       9 | 
      10 | it('renders correctly', () => {
1 Answers

Change file name from Link.react.js to Link.js. And change in the link.react.test.js file the path to Link. Sorry, I don't know exactly why it will work :)

Related