Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Aug 27, 2021
1 parent b203951 commit 5adf815
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/babel-parser/test/error-codes.js
Expand Up @@ -18,4 +18,25 @@ describe("error codes", function () {
expect(error.code).toBe("BABEL_PARSER_SYNTAX_ERROR");
expect(error.reasonCode).toBe("MissingSemicolon");
});
it("consistent reasonCode between Flow and TypeScript in Babel 8", () => {
const code = `function f([]?) {}`;
const {
errors: [tsError],
} = parse(code, {
errorRecovery: true,
plugins: ["typescript"],
});
const {
errors: [flowError],
} = parse(code, {
errorRecovery: true,
plugins: ["flow"],
});
expect(flowError.reasonCode).toBe(
process.env.BABEL_8_BREAKING
? tsError.reasonCode
: "OptionalBindingPattern",
);
expect(flowError.message).toBe(tsError.message);
});
});

0 comments on commit 5adf815

Please sign in to comment.