I am getting the warning Test functions cannot both take a 'done' callback and return something. Either use a 'done' callback, or return a promise.
Code is given below
it('step one validation on email based registration',async (done) => {
let inputVariations = [
{email:"",password:"",confirm_password:"",login_type:1},
{email:"test",password:"test",confirm_password:"test",login_type:1},
];
inputVariations.forEach(async (input) => {
var tabValidation = await validateStepOne.safeParseAsync({
email : input.email,
password : input.password,
confirm_password : input.confirm_password,
login_type : input.login_type
});
if (tabValidation) {
if (!tabValidation.success) {
if (tabValidation.error.issues.length > 0) {
let errorObj = {};
let errors = [];
for (var i = 0; i < tabValidation.error.issues.length; i++) {
errorObj = {};
errorObj.field = tabValidation.error.issues[i].path[0];
errorObj.message = tabValidation.error.issues[i].message;
errors.push(errorObj)
}
errors.forEach((errObj) => {
try{
if(errObj.field === "email"){
expect(emailErrors).toContain(errObj.message);
done();
}
}catch(err){
console.log(err.message)
}
})
}
}
}
});
});
Issue I have encounted is also given below
✓ Initialize test (3 ms)
✕ step one validation on email based registration (20 ms)
✓ Ending test
› step one validation on email based registration
Test functions cannot both take a 'done' callback and return something. Either use a 'done' callback, or return a promise.
Returned value: Promise {}
Can I do multiple test cases without encounting these errors
1