my ajax function somehow not covered by istanbul

Multi tool use
my ajax function somehow not covered by istanbul
I have a question I have this function
authAnonymous: function (callback) {
rest
.post(wso2config.token.host + "/" + wso2config.token.path, {
username: wso2config.clientId,
password: wso2config.clientSecret,
data: {
username: wso2config.anonymousUser.username,
password: wso2config.anonymousUser.password,
grant_type: "password",
redirect_uri: wso2config.redirect_uri,
scope: "somescope:thisisit"
}
})
.on("complete", function (data) {
if (data.error) callback(data, null);
else {
data.anonym = true;
callback(null, {
openid_data: data
});
}
});
},
so i want to code coverage this function and i make some unit test using Jest here's the unit test code
test("do login using authAnonymous", done => {
openID.authAnonymous(function (error, data) {
if (!error) {
expect(data.anonym).toBeTruthy();
} else {
//expect(data.anonym).toBe(false);
}
});
done();
});
somehow this unit test is working as I expected but code coverage says the statement is not covered
this says statement is not covered
as i understand my code works fine and unit test is working as expected why jest code coverage says this statement not covered can anyone explain how this statement covered works ? and why mine is not covered, i believe this is my fault but i don't know what to investigate here
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.