The current test suite is using snapshot testing to ensure the AST we generate for a particular fixture file doesn't change. This approach works well but requires manual validation, since we want to make sure that the snapshot generated is indeed correct.
Another approach to testing the parser that I'd like to try out is comparing the original code with a format-preserved print of the AST that we generate.
The idea here is to take the AST and use the Span information for each node to generate a 1:1 copy of the original code. This will make testing much easier since we'd just need to compare the two strings and will help us catch any precedence bugs, etc.
The current test suite is using snapshot testing to ensure the AST we generate for a particular fixture file doesn't change. This approach works well but requires manual validation, since we want to make sure that the snapshot generated is indeed correct.
Another approach to testing the parser that I'd like to try out is comparing the original code with a format-preserved print of the AST that we generate.
The idea here is to take the AST and use the
Span
information for each node to generate a 1:1 copy of the original code. This will make testing much easier since we'd just need to compare the two strings and will help us catch any precedence bugs, etc.