[test262] Strip codeframes from Forget errors so results are grouped

correctly
This commit is contained in:
Lauren Tan
2023-01-20 11:47:11 -05:00
parent 44beb3c023
commit b44f507c92

View File

@@ -13,6 +13,7 @@ module.exports = (test) => {
message = message.replace(/^\/.*?:\s/, ""); // babel seems to output filenames
message = message.split(/\(\d+:\d+\)/)[0]; // some errors report line numbers and codeframes
message = message.trim();
message = formatReactForgetErrorMessage(message);
// For unknown reasons I don't have the energy to dig into some Babel error instances can't be
// written to, so we construct a psedudo object here so the correctly formatted error messages
@@ -26,3 +27,12 @@ module.exports = (test) => {
return test;
};
function formatReactForgetErrorMessage(message) {
// Strip codeframes so we can group errors
const matches = message.match(/^\[ReactForget\].*\n?/);
if (Array.isArray(matches) && matches.length > 0) {
return matches[0].replace("\n", "");
}
return message;
}