Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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', () => {
like image 327
Thomas Avatar asked Jun 28 '26 01:06

Thomas


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 :)

like image 100
Oleksii Avatar answered Jun 29 '26 15:06

Oleksii