[英]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
. 我试图在https://jestjs.io/docs/en/tutorial-react之后设置jest测试我已经安装了与jest相关的依赖项,创建了
__test__/link.react.test.js
和Link.react.js
。 Following is my structure: 以下是我的结构:
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', () => {
Change file name from Link.react.js
to Link.js
. 将文件名从
Link.react.js
更改为Link.js
And change in the link.react.test.js
file the path to Link
. 并在
link.react.test.js
文件中更改Link
的路径。 Sorry, I don't know exactly why it will work :) 对不起,我不知道为什么它会起作用:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.