<rootdir>似乎无法用于package.json

时间:2018-12-03 19:32:18

标签: reactjs webpack jestjs babeljs enzyme

我想在测试中使用带有酶的开玩笑,并且基于该文档https://airbnb.io/enzyme/docs/guides/jest.html,我对package.json进行了如下更改:

.... "jest": { "setupTestFrameworkScriptFile": "<rootDir>/setupTests.js", "moduleFileExtensions": [ "js", "jsx" ], "moduleDirectories": [ "node_modules", "bower_components", "shared" ] }

我创建了setupTests.js,并将其添加到项目根目录:

import { configure } from 'enzyme' import Adapter from 'enzyme-adapter-react-16' configure({ adapter: new Adapter() })

项目结构:

setupTests.js package.json .babelrc .eslintrc jest.config.js \client \components \__TESTS__ footer.spec.js actions.spec.js ..... \pages \server

问题是当我运行jest时出现错误,因为找不到setupTests.js

enter image description here

我也应该在webpack上进行任何更改吗?

0 个答案:

没有答案