lundi 29 avril 2019

How to fail a nightwatch.js test within an if failure

I have an if statement that, when it 'fails', I'd like it to fail my nightwatch test.

So at the moment an excerpt of my code looks like this;

   if (rangeFacetEntry.value.length === rangePageElement.length) {
     if (JSON.stringify(rangeArray) === JSON.stringify(rangePageElement)) {
       console.log("Range - they are the same");
         return true;
           } else {
               console.log("Range - they are not the same");
                 return false;
             }
           }
     });

But when it fails (i.e. JSON.stringify(rangeArray) does not equal JSON.stringify(rangePageElement)) then I would like it to fail my test.

But it doesn't.

It simply doesn't output the result to the terminal, and the overall test passes.

Is there a way I can make this failure within my if statement implicitly fail my test? Thanks.

Aucun commentaire:

Enregistrer un commentaire