我使用spyOnProperty
监视我的两个属性并且他们在intellij
控制台中正常工作以在浏览器中进行业力测试和调试模式但是当我使用phantomjs运行它们时它们会给我下面提到的错误
我用来测试的代码
const div = fixture.debugElement.query(By.css('.xxxx'));
div.triggerEventHandler('mouseover', null);
fixture.detectChanges();
expect(component.tooltip.isOpen()).toBeFalsy();
// now spying on to see if its behavior changes
spyOnProperty(div.nativeElement, 'clientWidth', 'get').and.returnValue(1400);
spyOnProperty(div.nativeElement, 'scrollWidth', 'get').and.returnValue(2400);
PhantomJS 2.1.1 (Mac OS X 0.0.0) EllipsisOverflowComponent should show tooltip on mouse over of the element FAILED
Error: clientWidth is not declared configurable in http://localhost:9877node_modules/jasmine-core/lib/jasmine-core/jasmine.js (line 4410)
http://localhost:9877/_karma_webpack_/main.bundle.js:8593:22
invoke@http://localhost:9877/_karma_webpack_/polyfills.bundle.js:12949:31
onInvoke@http://localhost:9877/_karma_webpack_/vendor.bundle.js:136846:45
invoke@http://localhost:9877/_karma_webpack_/polyfills.bundle.js:12948:40
run@http://localhost:9877/_karma_webpack_/polyfills.bundle.js:12699:49
http://localhost:9877/_karma_webpack_/vendor.bundle.js:136543:37
http://localhost:9877/_karma_webpack_/vendor.bundle.js:183754:31
invoke@http://localhost:9877/_karma_webpack_/polyfills.bundle.js:12949:31
onInvoke@http://localhost:9877/_karma_webpack_/vendor.bundle.js:136080:45
onInvoke@http://localhost:9877/_karma_webpack_/vendor.bundle.js:136843:47
invoke@http://localhost:9877/_karma_webpack_/polyfills.bundle.js:12948:40
run@http://localhost:9877/_karma_webpack_/polyfills.bundle.js:12699:49
http://localhost:9877/_karma_webpack_/vendor.bundle.js:183749:28
http://localhost:9877/_karma_webpack_/vendor.bundle.js:136069:46
invokeTask@http://localhost:9877/_karma_webpack_/polyfills.bundle.js:12982:36
runTask@http://localhost:9877/_karma_webpack_/polyfills.bundle.js:12749:57
invoke@http://localhost:9877/_karma_webpack_/polyfills.bundle.js:13044:45
timer@http://localhost:9877/_karma_webpack_/polyfills.bundle.js:14070:34