mermaid/packages/parser/tests/test-util.ts
2023-08-26 14:06:41 +03:00

20 lines
548 B
TypeScript

import type { 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();
}