输入未在测试中用于离子输入

问题描述 投票:0回答:1

我有一个简单的表单,其中包含两个字段:用户名和电子邮件。我的测试看起来像这样:

...
fit('should create', () => {
    console.log(fixture.debugElement.nativeElement.childNodes);
    expect(component).toBeTruthy();
  });
....

我刚刚将console.log添加到生成的规格文件中。从下面的输出中可以看到,离子输入元素不包含输入元素。你知道为什么吗? (我需要它来运行附加到输入的模糊处理程序)

LOG: NodeList{0: <form _ngcontent-a-c0="" novalidate="" ng-reflect-form="[object Object]" class="ng-untouched ng-pristine ng-invalid"><div _ngcontent-a-c0=""><!--bindings={
  "ng-reflect-ng-if": "false"
}--><ion-item _ngcontent-a-c0="" class="ion-untouched ion-pristine ion-invalid"><!--bindings={
  "ng-reflect-ng-if": "true"
}--><ion-label _ngcontent-a-c0="" color="medium" position="floating" ng-reflect-color="medium" ng-reflect-position="floating">Username</ion-label><!--bindings={
  "ng-reflect-ng-if": "false"
}--><!--bindings={
  "ng-reflect-ng-if": "false"
}--><!--bindings={
  "ng-reflect-ng-if": "false"
}--><!--bindings={
  "ng-reflect-ng-if": "false"
}--><!--bindings={
  "ng-reflect-ng-if": "false"
}--><ion-input _ngcontent-a-c0="" formcontrolname="username" type="text" ng-reflect-type="text" ng-reflect-name="username" class="ng-untouched ng-pristine ng-invalid ion-untouched ion-pristine ion-invalid"></ion-input></ion-item><ion-item _ngcontent-a-c0="" class="ion-untouched ion-pristine ion-valid"><!--bindings={
  "ng-reflect-ng-if": "true"
}--><ion-label _ngcontent-a-c0="" color="medium" position="floating" ng-reflect-color="medium" ng-reflect-position="floating">Email</ion-label><!--bindings={
  "ng-reflect-ng-if": "false"
}--><ion-input _ngcontent-a-c0="" formcontrolname="email" readonly="true" type="email" ng-reflect-readonly="true" ng-reflect-type="email" ng-reflect-name="email" class="ng-untouched ng-pristine ng-valid ion-untouched ion-pristine ion-valid"></ion-input></ion-item><ion-input _ngcontent-a-c0="" formcontrolname="token" type="hidden" ng-reflect-type="hidden" ng-reflect-name="token" class="ng-untouched ng-pristine ng-invalid ion-untouched ion-pristine ion-invalid"></ion-input></div><div _ngcontent-a-c0="" class="ion-padding-top"><ion-button _ngcontent-a-c0="" expand="block" size="large" type="submit" ng-reflect-disabled="true" ng-reflect-expand="block" ng-reflect-size="large" ng-reflect-type="submit">Register</ion-button></div></form>}
ionic-framework ionic4
1个回答
0
投票

您可以使用:

await element(by.css('ion-input[formControlName="something"] input'))

获得可与之交互的离子输入的输入。

© www.soinside.com 2019 - 2024. All rights reserved.