When exceptions bubble up to k6, it only fails the current test iteration without failing the whole test. I understand I can catch the exception and call test.abort myself to do that. I would like to make that happen for all my tests without manually wrapping every scenario I have.
Is there a supported way to do that? I imagine there may be hooks somewhere in the executor(?) for this kind of things but I have failed to find any reference to this in the documentation.
Basically I would like to inject something like this into whatever is calling my exec functions:
function abortOnException() {
const wrappedFunction = arguments[0];
const args = Array.from(arguments).slice(1);
try {
return arguments[0].apply(this, args);
} catch (e) {
test.abort(`Exception while calling ${wrappedFunction}: ${e.stack}`);
}
}