create noErrorsOrAlternatives parser helper function

This commit is contained in:
Reda Al Sulais
2023-08-26 14:01:56 +03:00
parent 8186a54962
commit 21539dfb6a
2 changed files with 27 additions and 9 deletions

View File

@@ -0,0 +1,19 @@
import { ParseResult } from 'langium';
const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => {
return;
});
/**
* A helper test function that validate that the result doesn't have errors
* or any ambiguous alternatives from chevrotain.
*
* @param result - the result `parse` function.
*/
export function noErrorsOrAlternatives(result: ParseResult) {
expect(result.lexerErrors).toHaveLength(0);
expect(result.parserErrors).toHaveLength(0);
expect(consoleMock).not.toHaveBeenCalled();
consoleMock.mockReset();
}