开玩笑找不到模块

时间:2018-11-21 07:39:21

标签: reactjs webpack jestjs

我在package.json文件中有一个有趣的配置,如下所示

"jest": {
"transform": {
  "^.+\\.js$": "babel-jest",
  "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js"
},
"testPathIgnorePatterns": [
  "/node_modules/",
  "<rootDir>/__tests__/setupEnzyme.js",
  "<rootDir>/__tests__/shim.js",
  "<rootDir>/__tests__/setup.js",
  "<rootDir>/src/utils"
],
"moduleNameMapper": {
  "\\.(css|less|scss)$": "<rootDir>/__mocks__/styleMock.js"
},
"setupFiles": [
  "<rootDir>/__tests__/setup.js"
],
"setupTestFrameworkScriptFile": "<rootDir>/__tests__/setupEnzyme.js",
"snapshotSerializers": [
  "enzyme-to-json/serializer"
],
"moduleFileExtensions": [
  "js",
  "jsx"
],
"moduleDirectories": [
  "node_modules",
  "src",
  "assets"
]

}

我的package.json中有一个依赖项,如下所示

"dependencies": { "@something/react-components": "git+ssh://git@github.com/something/react-components.git#merged",

在我的Component.js文件中, import myFunction from '@something/react-components'

我运行jest --coverage时抛出错误 找不到模块'@something/react-components' from 'Component.js'

有人能让我知道可能是什么问题吗?

0 个答案:

没有答案
相关问题