chaijs / assertion-error

Error constructor for test and validation frameworks that implements standardized AssertionError specification.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed assertions are marked as successful

antonyhaman opened this issue · comments

Hi guys! I have faced with the strange problem that failed assertions (in case when this is the last assertion in the test) are marked as successful and the whole test is kinda like successful too, despite of assertion errors in the console.

Code:

this.Then("user sees that number of contacts is more than $count", function (count) {
  this.expect(this.getWidget('contacts').getNumberOfContacts()).to.eventually.be.above(count);
})

Output;

1 scenario (1 passed)
5 steps (5 passed)
0m03.890s
[17:58:25] E/launcher - expected 1 to be above 2
[17:58:25] E/launcher - AssertionError: expected 1 to be above 2
[17:58:25] E/launcher - Process exited with error code 199

@kotvertolet thanks for the issue.

Looks like you need to return this.expect as it is a Promise, and your test runner needs to get access to that to wait for the Promise to resolve; so:

this.Then("user sees that number of contacts is more than $count", function (count) {
  return this.expect(this.getWidget('contacts').getNumberOfContacts()).to.eventually.be.above(count);
})

Let us know if this fixes your issue. I'll close this for now, but if you're still experiencing the problem then let us know and we can re-open it. Thanks 😄

@keithamus now it works, thanks