Isahiro Isahiro - 3 months ago 111
TypeScript Question

How to import jasmine test functions in Angular2 rc5

I am working on a new project and just upgraded from rc4 to rc5 of Angular 2. Upon upgrading it appears that functions like it, expect, describe, etc are no longer being exported from '@angular/core/testing'. I have searched every resource I can think of and I see unit tests written online that claim to be using rc5 that still have these Jasmine test functions. Where do you import these from using rc5? Is there a new dependency library that I'm missing?

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"
}

Answer

They no longer need to be imported from anywhere as of RC4. They're made available globally to any testing module.

Importing Jasmine functions from @angular/core/testing is no longer necessary and is now deprecated.

See also the last bullet point of the Breaking Changes section of the RC4 Changelog.