如何在Angular2 rc5中导入jasmine测试函数

时间:2016-08-16 15:54:22

标签: unit-testing angular typescript karma-jasmine

我正在开发一个新项目,刚刚从Angular 2的rc4升级到rc5。升级后,似乎不再从'@ angular / core / testing'导出类似,期望,描述等功能。我搜索了我能想到的每一种资源,我看到在线编写的单元测试声称使用了仍然具有这些Jasmine测试功能的rc5。你从哪里使用rc5导入这些?是否有一个我缺少的新依赖库?

的package.json

"dependencies": {
  "@angular/common": "2.0.0-rc.5",
  "@angular/compiler": "2.0.0-rc.5",
  "@angular/core": "2.0.0-rc.5",
  "@angular/forms": "0.3.0",
  "@angular/http": "2.0.0-rc.5",
  "@angular/platform-browser": "2.0.0-rc.5",
  "@angular/platform-browser-dynamic": "2.0.0-rc.5",
  "@angular/router": "3.0.0-alpha.7",
  "@angular/router-deprecated": "2.0.0-rc.2",
  "@angular/upgrade": "2.0.0-rc.5",
  "@angular2-material/card": "^2.0.0-alpha.4",
  "@angular2-material/checkbox": "^2.0.0-alpha.4",
  "@angular2-material/core": "^2.0.0-alpha.4",
  "@angular2-material/sidenav": "^2.0.0-alpha.4",
  "@angular2-material/toolbar": "^2.0.0-alpha.4",
  "bootstrap": "twbs/bootstrap#v4-dev",
  "es6-shim": "^0.35.0",
  "font-awesome": "^4.6.3",
  "fullcalendar": "^2.7.3",
  "jquery": "^2.2.4",
  "jquery-datetimepicker": "^2.5.4",
  "jquery-ui": "^1.10.5",
  "material-icons": "^0.1.0",
  "moment": "^2.13.0",
  "ng2-bootstrap": "^1.0.22",
  "primeng": "^1.0.0-beta.8",
  "primeui": "^4.1.12",
  "reflect-metadata": "0.1.3",
  "rxjs": "5.0.0-beta.6",
  "sweetalert": "^1.1.3",
  "systemjs": "0.19.26",
  "zone.js": "^0.6.12"
},
  "devDependencies": {
  "angular-cli": "^1.0.0-beta.0",
  "clang-format": "^1.0.35",
  "codelyzer": "0.0.14",
  "ember-cli-inject-live-reload": "^1.4.0",
  "jasmine-core": "^2.4.1",
  "jasmine-spec-reporter": "^2.4.0",
  "karma": "^0.13.15",
  "karma-chrome-launcher": "^0.2.3",
  "karma-jasmine": "^0.3.8",
  "protractor": "^3.3.0",
  "ts-node": "^0.5.5",
  "tslint": "^3.6.0",
  "typescript": "^1.8.10",
  "typings": "^0.8.1"
}

1 个答案:

答案 0 :(得分:5)

从RC4起,它们不再需要从任何地方导入。它们可以在全球范围内用于任何测试模块。

  

不再需要从@angular/core/testing导入Jasmine函数,现在已弃用。

另请参阅Breaking Changes section of the RC4 Changelog的最后一个要点。