0

我正在监视我的两个属性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
4

0 回答 0