当我尝试为fixture.debugElement.nativeElement
的属性赋值时,它会给我错误。
fixture.debugElement.nativeElement.clientWidth = 4501;
我检入了调试器,fixture.debugElement.nativeElement.clientWidth
存在,而不是undefined
或null
。
TypeError: Cannot assign to read only property 'clientWidth' of object '[object HTMLDivElement]'
at Object.<anonymous> Users/k26686/aniruddh/develop/experiment/udc-spet-experiment/pre-commit-keywords/shepherd/src/app/shared/components/ellipsis-overflow/ellipsis-overflow.component.spec.ts:67:51)
...
Users/k26686/aniruddh/develop/experiment/udc-spet-experiment/pre-commit-keywords/shepherd/node_modules/zone.js/dist/zone.js:141:1)
at Object.<anonymous> Users/k26686/aniruddh/develop/experiment/udc-spet-experiment/pre-commit-keywords/shepherd/node_modules/zone.js/dist/jasmine-patch.js:104:1)
TypeError: Attempted to assign to readonly property. in http://localhost:9876/_karma_webpack_/main.bundle.js (line 14691)
http://localhost:9876/_karma_webpack_/main.bundle.js:14691:43
invoke@http://localhost:9876/_karma_webpack_/polyfills.bundle.js:12951:31
onInvoke@http://localhost:9876/_karma_webpack_/vendor.bundle.js:136846:45