[test262] Strip codeframes from Forget errors so results are grouped
correctly
Lauren Tan committed
Jan 20, 2023 at 11:47 UTC
b44f507c9212b49598fa7aa4d82ad47f0932ebaf
1 file changed
+10
compiler/forget/scripts/test262-preprocessor.js
+10
@@ -13,6 +13,7 @@ module.exports = (test) => {
13
message = message.replace(/^\/.*?:\s/, ""); // babel seems to output filenames
14
message = message.split(/\(\d+:\d+\)/)[0]; // some errors report line numbers and codeframes
15
message = message.trim();
16
+ message = formatReactForgetErrorMessage(message);
17
18
// For unknown reasons I don't have the energy to dig into some Babel error instances can't be
19
// written to, so we construct a psedudo object here so the correctly formatted error messages
@@ -26,3 +27,12 @@ module.exports = (test) => {
27
28
return test;
29
};
30
+
31
+function formatReactForgetErrorMessage(message) {
32
+ // Strip codeframes so we can group errors
33
+ const matches = message.match(/^\[ReactForget\].*\n?/);
34
+ if (Array.isArray(matches) && matches.length > 0) {
35
+ return matches[0].replace("\n", "");
36
+ }
37
+ return message;
38
+}