mermaid/packages/parser/tests/test-util.ts
Reda Al Sulais 24d43849a0 chore: apply review suggestions
* pref: optimize `common` rules and matchers
* chore: rename diagrams services to short form
* chore: sort imports
2023-09-07 00:24:00 +03:00

19 lines
581 B
TypeScript

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