Skip to content

Commit

Permalink
Fix serializer for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Mar 26, 2021
1 parent 311d2dd commit 18b44b8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/babel-parser/test/helpers/runFixtureTests.js
Expand Up @@ -233,8 +233,18 @@ function serialize(value) {
flags: value.flags,
};
} else if (value instanceof Error) {
// Errors are serialized to a simple string, because are used frequently
return value.toString();
const serializedError = {
[serialized]: "Error",
message: value.message,
name: value.name,
};
if (value.code) {
serializedError.code = value.code;
}
if (value.reasonCode) {
serializedError.reasonCode = value.reasonCode;
}
return serializedError;
}
return value;
}
Expand Down

0 comments on commit 18b44b8

Please sign in to comment.