Protractor 使用量角器测试有角度的腹板构件(自定义图元)

Protractor 使用量角器测试有角度的腹板构件(自定义图元),protractor,custom-element,angular11,angular12,Protractor,Custom Element,Angular11,Angular12,当我们在index.html中使用angular自定义元素标记并使用量角器运行e2e测试时,会导致超时,因为在页面中找不到angular,而对于angular web组件,只有entryComponents,没有bootstrap组件。因为构建用于部署为自定义元素的angular应用程序不需要对组件进行引导。要使用customElement构建用于生产的angular项目,并通过引导组件在量角器中测试相同的模块,下面的模块引导调整将起作用 @NgModule({ declarations

当我们在index.html中使用angular自定义元素标记并使用量角器运行e2e测试时,会导致超时,因为在页面中找不到angular,而对于angular web组件,只有entryComponents,没有bootstrap组件。因为构建用于部署为自定义元素的angular应用程序不需要对组件进行引导。

要使用customElement构建用于生产的angular项目,并通过引导组件在量角器中测试相同的模块,下面的模块引导调整将起作用

@NgModule({
    declarations: [AppComponent],
    imports: [
        BrowserModule,
        HttpClientModule
    ],
    providers: [],
    entryComponents: [AppComponent]
})
export class AppModule {
    constructor(private injector: Injector) {}

    ngDoBootstrap(appRef: ApplicationRef): void {
        if (environment.production) {
            const aboutSystemCustomElement = createCustomElement(AppComponent, { injector: this.injector });
            customElements.define('custom-app-component', AppComponent);
        } else {
            appRef.bootstrap(AppComponent);
        }
    }
}