Skip to content

Validation Test Helper #413

Answered by msujew
MathiasSJacobsen asked this question in Q&A
Feb 17, 2022 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

Hi @MathiasSJacobsen,

we expose some testing functionality in the framework, but none for validation so far. For a quick custom setup you could simply check whether the diagnostics returned from the DocumentValidator match whatever you expect. If you want a simple regression test, you could do something like this:

First iteration: Setting up the test

const services = createLanguageServices();
const helper = parseHelper<RootAST>(services);
const documentContent = "...";

(async function () {
  const doc = await helper(documentContent);
  const diagnostics = await services.validation.DocumentValidator.validateDocument(doc);
  console.log(JSON.stringify(diagnostics, undefined, 2)); // Store …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@MathiasSJacobsen
Comment options

@spoenemann
Comment options

@msujew
Comment options

@MathiasSJacobsen
Comment options

@MathiasSJacobsen
Comment options

Answer selected by MathiasSJacobsen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants