Unhandled exceptions from the axios library result in the following (even though all promises are properly awaited):
Unhandled rejection in example.test.js
DOMException {}
Whereas I would expect something like
axios test
Rejected promise returned by test. Reason:
Error {
...
}
Root Cause & Suggesion
This is happening because AVA sends transmits message about events like test failure due to exceptions being raised via a channel that requires serialization, and apparently these axios exceptions are not serializable. It would be nice if the outcome were less bad in this scenario. I can understand is isn't going to be possible to provide the same fidelity in this scenario, but it would be nice if the serialization issue could be caught, and instead of sending the full error object, just send an abbreviation (like the message and stack trace, possibly with some kind of warning that serialization of the original error was not possible). As it is the outcome is extremely hard to debug.
Reproducible example (run this test, with no special config):
import test from "ava";
import axios from "axios";
async function notGood() {
const res = await axios.post("http://nothing/bork");
return res.status;
}
test("axios test", async (t) => {
const val = await notGood();
t.truthy(val);
});
Unhandled exceptions from the
axios
library result in the following (even though all promises are properly awaited):Whereas I would expect something like
Root Cause & Suggesion
This is happening because AVA sends transmits message about events like test failure due to exceptions being raised via a channel that requires serialization, and apparently these axios exceptions are not serializable. It would be nice if the outcome were less bad in this scenario. I can understand is isn't going to be possible to provide the same fidelity in this scenario, but it would be nice if the serialization issue could be caught, and instead of sending the full error object, just send an abbreviation (like the message and stack trace, possibly with some kind of warning that serialization of the original error was not possible). As it is the outcome is extremely hard to debug.
Reproducible example (run this test, with no special config):
Versions