0
我使用ng-pattern进行验证,使用ng-show显示错误消息。这在浏览器上工作正常,但我如何在e2e中编码以测试错误消息是否显示?Angular e2e测试ng-show
这里是我的HTML:
<input type="text" ng-model="test.pname" name="pname" ng-maxlength="30" ng-pattern="/^[a-zA-Z0-9 ]*$/"/>
<span class="custom-error" id="pnameValidate" ng-show="addProviderForm.pname.$error.pattern">
PName can be Alpha-Numeric up to 30 characters – spaces allowed, but no special characters</span>
这里是我的E2E脚本:
input('test.pname').enter('cakes`');
expect(element('#pnameValidate:visible').text()).toMatch(/up to 30 characters/);
input('test.pname').enter('cakes are good');
expect(element('#pnameValidate:visible').text()).toBe('');
下面是测试运行的结果:
expected "" but was "\n PName can be Alpha-Numeric up to 30 characters – spaces allowed, but no special characters"
似乎在测试运行无论我在e2e中指定什么,#pnameValidate总是显示。