lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 137 forks source link

Facing issues with Cannot read property 'activeElement' of undefined! while running the unit testing #213

Closed Asiq closed 7 years ago

Asiq commented 7 years ago

After updating the latest version, I am facing this issues while running the unit test cases.

"dependencies": { "@angular/common": "2.2.1", "@angular/compiler": "2.2.1", "@angular/core": "2.2.1", "@angular/forms": "2.2.1", "@angular/http": "2.2.1", "@angular/platform-browser": "2.2.1", "@angular/platform-browser-dynamic": "2.2.1", "@angular/platform-server": "2.2.1", "@ionic/storage": "1.1.7", "ionic-angular": "2.0.0-rc.5", "@ng-idle/core": "^2.0.0-beta.4", "@ng-idle/keepalive": "^2.0.0-beta.4", "angular2-moment": "^1.0.0", "ionic-native": "2.2.11", "ionicons": "3.0.0", "rxjs": "5.0.0-beta.12", "zone.js": "0.6.26", "sw-toolbox": "3.4.0" }, "devDependencies": { "@angular/compiler-cli": "2.2.1", "@ionic/app-scripts": "1.0.0", "@types/jasmine": "2.5.38", "@types/node": "6.0.42", "angular-cli": "1.0.0-beta.25.5", "codecov": "1.0.1", "groundskeeper": "^0.1.12", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.7.0", "karma": "1.3.0", "karma-chrome-launcher": "2.0.0", "karma-cli": "1.0.1", "karma-jasmine": "1.1.0", "karma-mocha-reporter": "2.2.1", "karma-remap-istanbul": "0.2.2", "protractor": "4.0.13", "protractor-jasmine2-screenshot-reporter": "0.3.2", "ts-node": "1.7.2", "tslint": "4.1.1", "tslint-eslint-rules": "3.2.0", "typescript": "2.0.10" },

Error: Error in ./TextInput class TextInput - inline template:0:535 caused b y: Cannot read property 'activeElement' of undefined TypeError: Cannot read property 'activeElement' of undefined at Platform.getActiveElement (webpack:///~/ionic-angular/platform/platfo rm.js:640:0 <- src/test.ts:2670:25) at Platform.hasFocus (webpack:///~/ionic-angular/platform/platform.js:64 6:0 <- src/test.ts:2676:33)

lathonez commented 7 years ago

You need to use the PlatformMock as of rc5, see the changelog:

https://github.com/lathonez/clicker/blob/master/CHANGELOG.md