AssertionError:预期[true]为true [英] AssertionError: expected [ true ] to be true

查看:164
本文介绍了AssertionError:预期[true]为true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了奇怪的断言问题,因此即使成功的断言也被标记为失败,像这样:

I have faced with the strange assertions problem so even successful assertions are marked as failed, like this:

this.expect(this.getWidget('contacts').isNamesDisplayed()).to.eventually.be.true.and.notify(next);

,在控制台中,我有:


1个场景(1个通过)
4个步骤(4个通过)
0m03.618s
[17:06:38] E / launcher-预期[true]是真实的
[17:06:38] E / launcher-AssertionError:预期[true]是真实的

1 scenario (1 passed) 4 steps (4 passed) 0m03.618s [17:06:38] E/launcher - expected [ true ] to be true [17:06:38] E/launcher - AssertionError: expected [ true ] to be true

正如您在本例中看到的那样,尽管断言失败,但测试仍被标记为成功,但是如果在断言断言之后又有一个断言,则整个事情都会失败。

As you see in this case test marked as successful despite of failed assertion, but in case when after 'failed' assertion there is another one the whole thing will be failed.

我正在使用量角器和柴的最新版本。

I'm using the last versions of protractor and chai.

推荐答案

似乎是 this.getWidget('contacts')。isNamesDisplayed()返回一个数组值 [true] 而不是 true 。您需要按以下方式更改您的Expect语句。

It seems like this.getWidget('contacts').isNamesDisplayed() is returning an array value [true] instead of true. you need to change your expect statement as below.

this.expect(this.getWidget('contacts')。isNamesDisplayed())。to .eql([true])。and.notify(next);

这篇关于AssertionError:预期[true]为true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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