How to return test status - "fail" by should.js?

103 Views Asked by At

I using Nightwatch, Mocha and Should.js for testing. And in some cases I do check for text value of elements. My question is - How to make test status - "fail", when text value is not equals to expected value?

it("Test should return 'fail' status", function(client) {
    client
      .url(urlAddress)
      .waitForElementPresent("h1", config.middleTimer)
      .getText("h1", function(result) {
        result.value.should.be.exactly("Expected text!!!");
      })
      .end()
  });

1

There are 1 best solutions below

0
On

I found solution:

.getText("div.ui-notifications .error", function (result) {
        this.assert.equal(result.value, "Expected value");
      })

This construction will change test status to "fail"! "This" equals to mocha runner.