Function toHaveNoErrors

  • Expects a Langium document to have no errors after parsing. Non-error diagnostics are ignored by default.

    Parameters

    • document: LangiumDocument<AstNode> | ParsedDocument

      The Langium document or parsed document to check for errors.

    • Optionalparameters: IgnoreParameters

      Optional parameters to customize which errors to ignore.

    Returns { message: () => string; pass: boolean }

    import { expect, test } from 'vitest';
    import { parse } from './your-langium-test-setup';

    test('document has no errors', async () => {
    const doc = await parse('const x = 5;');
    expect(doc).toHaveNoErrors();
    });

    test('document has no errors, ignoring lexer errors', async () => {
    const doc = await parse('const x = @;', { validation: true });
    expect(doc).toHaveNoErrors({ ignoreLexerErrors: true });
    });