从create react app

时间:2019-07-10 13:53:21

标签: reactjs jestjs enzyme create-react-app

从create react应用程序弹出后无法运行测试。

第1步:弹出创建React应用

Step2:在package.json中,我们使用的是webpack 3.6,并做出反应:16.8.6

Step3:npm jest,npm酶,npm酶适配器-反应16,npm酶反应-intl和内部脚本:{test:jest},

第4步:npm测试

“脚本”:{       “ test”:“开玩笑”   },   “依赖关系”:{   “ jest”:“ ^ 24.8.0”,   “ enzyme”:“ ^ 3.10.0”,     “ enzyme-adapter-react-16”:“ ^ 1.14.0”,     “ enzyme-react-intl”:“ ^ 2.0.4”, }

带有intl测试用例的预期React组件应该通过 实际:  测试 /components/MapControls/SearchLocation.test.js   ●测试套件无法运行

Jest encountered an unexpected token

This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

Here's what you can do:
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html

Details:

SyntaxError: C:\Users\admin\Documents\UGVCS-Project\New FE checkout\frontend\app\_tests_\components\MapControls\SearchLocation.test.js: Unexpected token (12:37)

  10 |
  11 | test('submit co-ordinates and test null check', () =>{
> 12 |   const searchComp = shallowWithIntl(<SearchLocation  />);
     |                                      ^

0 个答案:

没有答案