I've found out how to test promises in jasmine, but I couldn't find a way to test the beforeSend method.
var xhr = $.ajax({
url: 'http://example.com',
type: 'POST',
data: '...',
beforeSend: function() {
methodToBeTested();
}
});
I do need the code to run before the request is sent so using the always promise is not an option.