mermaid/packages/parser/tests/test-util.ts

19 lines
581 B
TypeScript
Raw Normal View History

2023-08-26 14:06:41 +03:00
import type { ParseResult } from 'langium';
import { expect, vi } from 'vitest';
const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => undefined);
/**
* 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();
}