I'm trying to check whether a test passes or not, however I did not understand the syntax of how to create a condition and check the right / wrong. I believe that the condition is done within evaluate . This is my test using Nightmare.js :
var Nightmare = require("nightmare");
const chai = require("chai");
const nightmare = Nightmare();
describe("Login Page", function() {
this.timeout("30s");
let nightmare = null;
beforeEach(() => {
nightmare = new Nightmare({ show: false });
});
describe("Formulário", () => {
it("should be ok", done => {
nightmare
.goto("meusiteexemplo")
.type("#txtLogin", "[email protected]")
.type("#txtSenha", "123")
.click("button")
.wait()
.evaluate(() => {
if (document.location.href === "g") {
return document.location.href;
} else {
return "not passed";
}
})
.end();
done();
});
});
});
Remembering that the site and the forms data in the example are illustrative.