将Webpack别名与Jest对齐

时间:2018-10-04 13:33:33

标签: webpack jestjs

配置似乎与玩笑教程中的一样。但是有些东西不起作用...

objIE.document.querySelector("[id='uo_t_butt']").Click

Webpack别名工作正常(在浏览器中)

"jest": {
    "roots": [
      "<rootDir>/src"
    ],
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json"
    ],
    "moduleDirectories": [
      "node_modules"
    ],
    "setupFiles": [
      "<rootDir>/src/setup-kit/setup.ts"
    ],
    "moduleNameMapper": {
      "\\.(css|styl|less|sass|scss)$": "identity-obj-proxy",
      "^base-components(.*)$": "<rootDir>/src/base-components$1",
      "^components(.*)$": "<rootDir>/src/components$1"
    },
    "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
    "transform": {
      "^.+\\.tsx?$": "ts-jest",
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/setup-kit/__mock__/fileTransformer.js"
    }
  }

测试套件无法运行

从'component.tsx'中找不到模块'base-components / Icon'

完整跟踪在这里

enter image description here

0 个答案:

没有答案