Jasmin 测试用例在 Angular 14 上失败

问题描述 投票:0回答:0

无法在角度项目上使用业力框架执行单元测试。

{
 "dependencies": {
    "@angular-material-components/datetime-picker": "^7.0.1",
    "@angular/animations": "^14.3.0",
    "@angular/cdk": "^13.3.4",
    "@angular/common": "^14.3.0",
    "@angular/compiler": "^14.3.0",
    "@angular/core": "^14.3.0",
    "@angular/fire": "^6.1.4",
    "@angular/forms": "^14.3.0",
    "@angular/material": "^13.3.4",
    "@angular/material-moment-adapter": "^13.3.4",
    "@angular/platform-browser": "^14.3.0",
    "@angular/platform-browser-dynamic": "^14.3.0",
    "@angular/router": "^14.3.0",
    "lodash": "^4.17.21",
    "moment-timezone": "^0.5.34",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.2.11",
    "@angular/cli": "^14.2.11",
    "@angular/compiler-cli": "^14.3.0",
    "@cypress/schematic": "^1.6.0",
    "@types/file-saver": "^2.0.5",
    "@types/gtag.js": "^0.0.12",
    "@types/jasmine": "^4.3.1",
    "@types/lodash": "^4.14.182",
    "@types/node": "^12.20.48",
    "cypress": "latest",
    "firebase-tools": "^10.7.1",
    "karma": "^6.4.1",
    "karma-chrome-launcher": "^3.1.1",
    "karma-coverage-istanbul-reporter": "^3.0.3",
    "karma-jasmine": "^5.1.0",
    "karma-jasmine-html-reporter": "^2.0.0",
    "protractor": "~7.0.0",
    "ts-node": "^10.7.0",
    "tslib": "^2.3.0",
    "tslint": "^6.1.3",
    "typescript": "^4.6.3"
  }
}

重大变化:

webpack
< 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

如果你想包含一个 polyfill,你需要:

  • 添加后备
resolve.fallback: { "util": require.resolve("util/") }
  • 安装
    util
    。如果你不想包含一个 polyfill,你可以像这样使用一个空模块:
resolve.fallback: { "util": false }

我的配置有什么常见的错误吗?

angular karma-jasmine karma-runner
© www.soinside.com 2019 - 2024. All rights reserved.