Sorry, I forgot that frappe.confirm is a client-side method. Because these are async methods, you need to treat the prompt as a promise that you await:
frappe.ui.form.on('Test Doctype', {
before_submit: async (frm) => {
let prompt = new Promise((resolve, reject) => {
frappe.confirm(
'Are you sure?',
() => resolve(),
() => reject()
);
});
await prompt.then(
() => frappe.show_alert("Submitted", 3),
() => {
frappe.validated = false;
frappe.show_alert("Not submitted", 3)
}
);
}
})