【发布时间】:2019-02-22 16:50:44
【问题描述】:
我正在尝试在https://jestjs.io/docs/en/tutorial-react 之后设置玩笑测试我已经安装了玩笑相关的依赖项,创建了__test__/link.react.test.js 和Link.react.js。以下是我的结构:
但是,它有以下测试问题。但我的结构和两个文件与教程完全相同。
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', () => {
【问题讨论】:
-
您可以尝试将文件名从
Link.react.js更改为Link.js。并在link.react.test.js文件中更改Link的路径 -
有效!您能否请帖作为答案,我会接受。但是很奇怪,教程使用相同的文件名并且教程有效!我想知道你是否知道原因
-
这只是我的直觉建议。我认为系统无法识别文件扩展名是
js,因为文件名中有.react。