Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 1.27 KB

File metadata and controls

36 lines (26 loc) · 1.27 KB

How Can One Test for An Expected Error

Error node locations may vary across time but one might still want to have a test to express that an error is expected.

This can be achieved using the :error attribute feature of tree-sitter that was introduced in version 0.22.0 of the tree-sitter CLI tool.

Below is a sample test.

================================================================================
Invalid comment

:error
:language(xml)
================================================================================

<error>
<!-- invalid -- -->
</error>

--------------------------------------------------------------------------------

There are more examples here.

References