Javascript 在现有项目中配置jest和Ezyme时出错
我在一个现有的react项目中工作,我想在其中引入单元测试。为此,我正在使用Javascript 在现有项目中配置jest和Ezyme时出错,javascript,reactjs,jestjs,enzyme,babel-jest,Javascript,Reactjs,Jestjs,Enzyme,Babel Jest,我在一个现有的react项目中工作,我想在其中引入单元测试。为此,我正在使用enzyme配置jest。在package.json中,我添加了以下内容: "jest": { "verbose": true, "setupFilesAfterEnv": ["<rootDir>src/setupTests.js"], "moduleDirectories": [ "/node_modules" ] }, 我有setupTests.js以及e
enzyme
配置jest
。在package.json
中,我添加了以下内容:
"jest": {
"verbose": true,
"setupFilesAfterEnv": ["<rootDir>src/setupTests.js"],
"moduleDirectories": [
"/node_modules"
]
},
我有setupTests.js
以及enzyme
配置:
import Enzyme from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
Enzyme.configure({ adapter: new Adapter() })
现在,当我运行纱线测试时,我发现以下错误:
yarn run v1.12.3
$ jest
FAIL src/components/__tests__/TroveV5.test.js
● Test suite failed to run
Cannot find module 'source-map-support' from 'source-map-support.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:230:17)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 2.352s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
无法从“source map support.js”中找到模块“source map support”
我做错了什么
yarn run v1.12.3
$ jest
FAIL src/components/__tests__/TroveV5.test.js
● Test suite failed to run
Cannot find module 'source-map-support' from 'source-map-support.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:230:17)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 2.352s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.