I have several form fields that I'm testing with Chai Expect. I'm using a Try/Catch with return statements, but after all the wrong inputs (in the form) I get only one error, that is the first one, but I need to catch and log all the errors and I don't know what I'm doing wrong...Any help would be aprecciated. The code:
//CHAI EXPEXT
var inputs = [response.fname, response.surname, response.age, response.password, response.email, response.phone, response.city, response.country, response.postal_code];
for (var i = 0; i < inputs.length; i++) {
try{
expect(inputs[0]).to.be.NaN;
expect(inputs[7]).to.have.length.above(1);
expect(inputs[3]).to.have.length.above(6);
expect(inputs[4]).to.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/);
expect(inputs[4]).to.have.length.below(256);
expect(inputs[2]).not.to.be.NaN;
return "OK";
}catch(error){
console.log(error);
return error;
}
}
via FuManchu
No comments:
Post a Comment