Jest无法解析导入

时间:2017-11-05 12:53:37

标签: javascript reactjs redux jestjs

Jest以某种方式无法解析我文件的二次导入。

MyTest.js 有这一行:

import reducer from "./../AppReducer"

AppReducer.js 有这一行:

import { ActionXYZ} from './Actions.js'

对于ActionXYZ无法解析。如果我调试代码,那么ActionXYZ是一个有两个字符串的对象,如下所示:

message: "ReferenceError: ActionsXYZ is not defined"
stack "ReferenceError: ActionXYZ is not defined
    at eval (eval at t.evaluate (eval at <anonymous> (unknown source)), <anonymous>:1:1)
    at t.evaluate (eval at <anonymous> (unknown source), <anonymous>:165:98)
    at DebugCommandProcessor.t.processDebugJSONRequest (eval at <anonymous> (unknown source), <anonymous>:458:15)
    at AppReducer (C:\dev\react-charts\src\js\AppReducer.js:11:37)
    at dispatch (C:\dev\react-charts\node_modules\redux\lib\createStore.js:178:22)

为什么Jest这样做?否则我的申请会正常运行。

我的 package.json 中的我的jest配置设置如下所示:

  "jest": {
    "moduleNameMapper": {
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "./test/fileMock.js",
      "\\.(css|less)$": "<rootDir>/test/styleMock.js"
    }
  },

0 个答案:

没有答案