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 8515c467_ba4e_c0f9_a53d_1c6fb7a5b697["diagnostics.test.ts"] 923db4e1_01a0_98ab_9c38_dfe16dd4bada["server.ts"] 8515c467_ba4e_c0f9_a53d_1c6fb7a5b697 --> 923db4e1_01a0_98ab_9c38_dfe16dd4bada 9cf7acc9_e2e5_26e3_64f0_7304d1983c86["getLanguageServer"] 8515c467_ba4e_c0f9_a53d_1c6fb7a5b697 --> 9cf7acc9_e2e5_26e3_64f0_7304d1983c86 d8206fa8_f041_14e6_d043_1fc32953407c["utils.ts"] 8515c467_ba4e_c0f9_a53d_1c6fb7a5b697 --> d8206fa8_f041_14e6_d043_1fc32953407c db323e8c_04ef_9777_0487_224de5819a30["node:assert"] 8515c467_ba4e_c0f9_a53d_1c6fb7a5b697 --> db323e8c_04ef_9777_0487_224de5819a30 c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"] 8515c467_ba4e_c0f9_a53d_1c6fb7a5b697 --> c52a5f83_66e3_37d7_9ebb_767f7129bc62 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 8515c467_ba4e_c0f9_a53d_1c6fb7a5b697 --> 6b0635f9_51ea_77aa_767b_7857878e98a6 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56["language-server"] 8515c467_ba4e_c0f9_a53d_1c6fb7a5b697 --> 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56 style 8515c467_ba4e_c0f9_a53d_1c6fb7a5b697 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import assert from 'node:assert';
import * as path from 'node:path';
import { before, describe, it } from 'node:test';
import type { FullDocumentDiagnosticReport } from '@volar/language-server';
import { type Diagnostic, DiagnosticSeverity, Range } from '@volar/language-server';
import { getLanguageServer, type LanguageServer } from '../server.ts';
import { fixtureDir } from '../utils.ts';
describe('TypeScript - Diagnostics', async () => {
let languageServer: LanguageServer;
before(async () => (languageServer = await getLanguageServer()));
it('Can get diagnostics in the frontmatter', async () => {
const document = await languageServer.openFakeDocument('---\nNotAThing\n---', 'astro');
const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
document.uri,
)) as FullDocumentDiagnosticReport;
// We should only have one error here.
assert.strictEqual(diagnostics.items.length, 1);
// Data here is Volar specific, and is not too relevant to test. We'll throw it out.
const diagnostic: Diagnostic = { ...diagnostics.items[0], data: {} };
assert.deepStrictEqual(diagnostic, {
code: 2304,
data: {},
message: "Cannot find name 'NotAThing'.",
range: Range.create(1, 0, 1, 9),
severity: DiagnosticSeverity.Error,
source: 'ts',
});
});
it('Can get diagnostics in the template', async () => {
const document = await languageServer.openFakeDocument('---\n\n---\n{nope}', 'astro');
const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
document.uri,
)) as FullDocumentDiagnosticReport;
assert.strictEqual(diagnostics.items.length, 1);
const diagnostic: Diagnostic = { ...diagnostics.items[0], data: {} };
assert.deepStrictEqual(diagnostic, {
code: 2304,
data: {},
message: "Cannot find name 'nope'.",
range: Range.create(3, 1, 3, 5),
severity: DiagnosticSeverity.Error,
source: 'ts',
});
});
it('shows enhanced diagnostics', async () => {
const document = await languageServer.handle.openTextDocument(
path.join(fixtureDir, 'enhancedDiagnostics.astro'),
'astro',
);
const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
document.uri,
)) as FullDocumentDiagnosticReport;
assert.strictEqual(diagnostics.items.length, 1);
diagnostics.items = diagnostics.items.map((diag) => ({ ...diag, data: {} }));
assert.deepStrictEqual(diagnostics.items, [
{
code: 2322,
data: {},
message:
"Type '{ \"client:idle\": true; }' is not assignable to type 'HTMLAttributes'.\n Property 'client:idle' does not exist on type 'HTMLAttributes'.\n\nClient directives are only available on framework components.",
range: Range.create(0, 5, 0, 16),
severity: DiagnosticSeverity.Error,
source: 'ts',
},
]);
});
it('can get diagnostics in script tags', async () => {
const document = await languageServer.openFakeDocument(
`<script>const something: string = "Hello";something;</script><div><script>console.log(doesnotexist);</script></div>`,
'astro',
);
const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
document.uri,
)) as FullDocumentDiagnosticReport;
assert.strictEqual(diagnostics.items.length, 1);
});
});
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/typescript/diagnostics.test.ts (domain: CoreAstro, directory: packages/language-tools/language-server/test/typescript).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free