Angular Ace编辑器&x2B;角度2=>;量角器无法同步

Angular Ace编辑器&x2B;角度2=>;量角器无法同步,angular,protractor,ace-editor,angular-cli,Angular,Protractor,Ace Editor,Angular Cli,我正在使用Angular 2(2.0.0版本)、Angular cli(1.0.0-beta.14)开发一个应用程序 我已经使用Angular 2指令集成了Ace编辑器,如下所示 Ace编辑器实例化后,量角器将无法再同步: ✗ should display app name - Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://g

我正在使用Angular 2(2.0.0版本)、Angular cli(1.0.0-beta.14)开发一个应用程序

我已经使用Angular 2指令集成了Ace编辑器,如下所示

Ace编辑器实例化后,量角器将无法再同步:

✗ should display app name
  - Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md
While waiting for element with locator - Locator: By(css selector, app-root .navbar a.active)
Ace编辑器的实例化使用:

import { EventEmitter, Output, ElementRef, Input, Directive } from '@angular/core';
import 'brace';
import 'brace/theme/chrome';
import 'brace/mode/html';

declare var ace: any;

@Directive({
   selector: '[aceEditor]'
})
export class AceEditorDirective {
  editor: any;

  constructor(elementRef: ElementRef) {
    let el = elementRef.nativeElement;
    this.editor = ace['edit'](el); // Comment this line and Protractor works again
  }
}

有什么问题吗?

好的,终于找到问题了。 看起来Angular在Ace编辑器中无法跟踪更改,因此认为始终存在持续的更改。所以

window.getAngularTestability($('app-root'))
    .whenStable(funct‌​ion(){
        console.log('s‌​table')
    })
在实例化Ace编辑器时不再返回

简单解决方案:在区域外实例化Ace编辑器:

constructor(elementRef: ElementRef, zone: NgZone) {
  let el = elementRef.nativeElement;
  zone.runOutsideAngular(() => {
    this.editor = ace['edit'](el);
  });
}

我面临着与上面相同的问题,我没有在Angular之外运行ace编辑器,而是在量角器中进行了多个测试,这将从上一个测试停止的地方继续进行。Ace编辑器将导致浏览器无法完成同步,因此我的量角器测试将超时

您可以进行如下测试:

it('Runs Tests for components with ace edit')
  browser.ignoreSynchronization = true;
  testAngularElements();

it('Runs the rest of the test in which the ace edit is not present')
  browser.ignoreSynchronization = false;
  remainingTests();

不幸的是,我还没有找到替代方法。

看起来,当Ace编辑器被实例化时,Angular再也无法判断它是否已准备就绪:
window.getAngularTestability($('app-root'))。whenStable(function(){console.log('stable')})
不再打印任何内容。