diagnostics.test.ts — astro Source File
Architecture documentation for diagnostics.test.ts, a typescript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 93e35a50_6bb5_f8d8_542c_bf8226444c1c["diagnostics.test.ts"] 923db4e1_01a0_98ab_9c38_dfe16dd4bada["server.ts"] 93e35a50_6bb5_f8d8_542c_bf8226444c1c --> 923db4e1_01a0_98ab_9c38_dfe16dd4bada 9cf7acc9_e2e5_26e3_64f0_7304d1983c86["getLanguageServer"] 93e35a50_6bb5_f8d8_542c_bf8226444c1c --> 9cf7acc9_e2e5_26e3_64f0_7304d1983c86 d8206fa8_f041_14e6_d043_1fc32953407c["utils.ts"] 93e35a50_6bb5_f8d8_542c_bf8226444c1c --> d8206fa8_f041_14e6_d043_1fc32953407c db323e8c_04ef_9777_0487_224de5819a30["node:assert"] 93e35a50_6bb5_f8d8_542c_bf8226444c1c --> db323e8c_04ef_9777_0487_224de5819a30 c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"] 93e35a50_6bb5_f8d8_542c_bf8226444c1c --> c52a5f83_66e3_37d7_9ebb_767f7129bc62 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 93e35a50_6bb5_f8d8_542c_bf8226444c1c --> 6b0635f9_51ea_77aa_767b_7857878e98a6 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56["language-server"] 93e35a50_6bb5_f8d8_542c_bf8226444c1c --> 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56 style 93e35a50_6bb5_f8d8_542c_bf8226444c1c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import assert from 'node:assert';
import path from 'node:path';
import { before, describe, it } from 'node:test';
import type { FullDocumentDiagnosticReport } from '@volar/language-server';
import { DiagnosticSeverity, Position } from '@volar/language-server';
import { getLanguageServer, type LanguageServer } from '../server.ts';
import { fixtureDir } from '../utils.ts';
// TODO: We can't sync the fixture with these mistakes at all, as such we can't run these tests.
describe.skip(
'Content Intellisense - Diagnostics',
{ skip: parseInt(process.versions.node) === 20 },
async () => {
let languageServer: LanguageServer;
before(async () => {
languageServer = await getLanguageServer();
});
it('Report errors for missing entries in frontmatter', async () => {
const document = await languageServer.handle.openTextDocument(
path.join(fixtureDir, 'src', 'content', 'blog', 'missing_property.md'),
'markdown',
);
const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
document.uri,
)) as FullDocumentDiagnosticReport;
assert.strictEqual(diagnostics.items.length, 1);
const firstDiagnostic = diagnostics.items[0];
// The data is not super relevant to the test, so we'll throw it out.
delete firstDiagnostic.data;
assert.deepStrictEqual(firstDiagnostic, {
code: 0,
message: 'Missing property "description".',
range: {
start: Position.create(0, 0),
end: Position.create(2, 3),
},
severity: DiagnosticSeverity.Error,
source: 'astro',
});
});
it('Report errors for invalid types in frontmatter', async () => {
const document = await languageServer.handle.openTextDocument(
path.join(fixtureDir, 'src', 'content', 'blog', 'type_error.md'),
'markdown',
);
const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
document.uri,
)) as FullDocumentDiagnosticReport;
assert.strictEqual(diagnostics.items.length, 1);
const firstDiagnostic = diagnostics.items[0];
delete firstDiagnostic.data;
assert.deepStrictEqual(firstDiagnostic, {
code: 0,
message: 'Incorrect type. Expected "string".',
range: {
start: Position.create(1, 7),
end: Position.create(1, 8),
},
severity: DiagnosticSeverity.Error,
source: 'astro',
});
});
it('Report error for missing frontmatter', async () => {
const document = await languageServer.handle.openTextDocument(
path.join(fixtureDir, 'src', 'content', 'blog', 'no_frontmatter.md'),
'markdown',
);
const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
document.uri,
)) as FullDocumentDiagnosticReport;
assert.strictEqual(diagnostics.items.length, 1);
const firstDiagnostic = diagnostics.items[0];
delete firstDiagnostic.data;
assert.deepStrictEqual(firstDiagnostic, {
message: 'Frontmatter is required for this file.',
range: {
start: Position.create(0, 0),
end: Position.create(0, 0),
},
severity: DiagnosticSeverity.Error,
});
});
},
);
Domain
Dependencies
- getLanguageServer
- language-server
- node:assert
- node:path
- node:test
- server.ts
- utils.ts
Source
Frequently Asked Questions
What does diagnostics.test.ts do?
diagnostics.test.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain.
What does diagnostics.test.ts depend on?
diagnostics.test.ts imports 7 module(s): getLanguageServer, language-server, node:assert, node:path, node:test, server.ts, utils.ts.
Where is diagnostics.test.ts in the architecture?
diagnostics.test.ts is located at packages/language-tools/language-server/test/content-intellisense/diagnostics.test.ts (domain: CoreAstro, directory: packages/language-tools/language-server/test/content-intellisense).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free