0

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()
  });
Arsenowitch
  • 401
  • 5
  • 22

1 Answers1

0

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.

Arsenowitch
  • 401
  • 5
  • 22