获得“不是可以接受的”。消息同时使用“最终”消息在量角器柴 [英] Getting "is not a thenable" message while using "eventually" in protractor chai

查看:40
本文介绍了获得“不是可以接受的”。消息同时使用“最终”消息在量角器柴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试验证以下条件时。

  var val1 = ONE; 
var val2 =两个;
Expect(val1 == val2)最终等于(false)

I '得到 false并不是可以接受的消息,如果我最终删除了如下的条件,那么它可以正常工作。

  var val1 = ONE; 
var val2 =两个;
Expect(val1 == val2).to.equal(false)

有人可以帮忙吗我了解差异。另外,如果条件失败,则会显示错误消息,并且不执行 hooks.js

解决方案

简而言之:



最终-是蔡氏承诺的一种方法。
如果您最终使用 量角器期望您断言价值承诺的结果(在这种情况下 false )。
val1 val2 是布尔值。 val1 val2 的比较也是一个布尔值。





您有两种可能:
1.最终不要使用(只是柴)。
2.通过比较这些值返回一个承诺。


When I tried to verify the condition as below.

 var val1 = "ONE";
 var val2 = "TWO";
 expect(val1==val2).to.eventually.equal(false)

I'm getting false is not a thenable message, If I removed eventually condition as below then it working fine.

 var val1 = "ONE";
 var val2 = "TWO";
 expect(val1==val2).to.equal(false)

Can anyone help me to understand the difference. Also If the condition fails, It displays the error message and not executing the hooks.js.

解决方案

In simple words:

eventually - is a method from chai-as-promised. If you use eventually protractor expects that you are asserting result of a promise to value (in this case false). val1 and val2 are bools. Comparison of val1 and val2 is also a bool.

Bool is not a promise.

You've got two possibilities: 1. Don't use eventually (just a chai). 2. Return a promise from comparison of those values.

这篇关于获得“不是可以接受的”。消息同时使用“最终”消息在量角器柴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆