基于umiJS,跑UT时报:‘“umi“‘ has no exported member named ‘history‘. Did you mean ‘History‘?

导读:本篇文章讲解 基于umiJS,跑UT时报:‘“umi“‘ has no exported member named ‘history‘. Did you mean ‘History‘?,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

1.1 现象

在这里插入图片描述

1.2 tsconfig.json

确保 tsconfig.json 中有配置 @@ 的路径,比如 "@@/*": ["src/.umi/*"]

例子:

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "jsx": "react-jsx",
    "esModuleInterop": true,
    "sourceMap": true,
    "baseUrl": "./",
    "strict": true,
    "paths": {
      "@/*": ["src/*"],
      "@@/*": ["src/.umi/*"]
    },
    "allowSyntheticDefaultImports": true
  },
  "include": [
    "mock/**/*",
    "src/**/*",
    "config/**/*",
    ".umirc.ts",
    "typings.d.ts"
  ],
  "exclude": [
    "node_modules",
    "lib",
    "es",
    "dist",
    "typings",
    "**/__test__",
    "test",
    "docs",
    "tests"
  ]
}

1.3 执行umi g tmp命令

在跑npm run test:jest之前,先执行一次npm run postinstall。对应的命令如下:

"scripts": {
	"postinstall": "umi g tmp",
	"test:jest": "jest --coverage --env=jest-environment-jsdom-sixteen",
}

1.4 CI/CD具体执行命令顺序

- npm install
- npm run postinstall
- npm run test:jest

1.5 解决

在这里插入图片描述
在这里插入图片描述

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由半码博客整理,本文链接:https://www.bmabk.com/index.php/post/77880.html

(0)

相关推荐

半码博客——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!