Home / File/ scripts.test.ts — astro Source File

scripts.test.ts — astro Source File

Architecture documentation for scripts.test.ts, a typescript file in the astro codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  b53e54b9_ddf4_0c07_fa4c_19139c354382["scripts.test.ts"]
  923db4e1_01a0_98ab_9c38_dfe16dd4bada["server.ts"]
  b53e54b9_ddf4_0c07_fa4c_19139c354382 --> 923db4e1_01a0_98ab_9c38_dfe16dd4bada
  9cf7acc9_e2e5_26e3_64f0_7304d1983c86["getLanguageServer"]
  b53e54b9_ddf4_0c07_fa4c_19139c354382 --> 9cf7acc9_e2e5_26e3_64f0_7304d1983c86
  db323e8c_04ef_9777_0487_224de5819a30["node:assert"]
  b53e54b9_ddf4_0c07_fa4c_19139c354382 --> db323e8c_04ef_9777_0487_224de5819a30
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  b53e54b9_ddf4_0c07_fa4c_19139c354382 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56["language-server"]
  b53e54b9_ddf4_0c07_fa4c_19139c354382 --> 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56
  style b53e54b9_ddf4_0c07_fa4c_19139c354382 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import assert from 'node:assert';
import { before, describe, it } from 'node:test';
import { type FullDocumentDiagnosticReport, Position, Range } from '@volar/language-server';
import { getLanguageServer, type LanguageServer } from '../server.ts';

describe('TypeScript - Diagnostics', async () => {
	let languageServer: LanguageServer;

	before(async () => (languageServer = await getLanguageServer()));

	it('treats script tags as modules', async () => {
		const document = await languageServer.openFakeDocument(
			'<script>import * as path from "node:path";path;const hello = "Hello, Astro!";</script><script>console.log(hello);</script>',
			'astro',
		);
		const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
			document.uri,
		)) as FullDocumentDiagnosticReport;

		assert.strictEqual(diagnostics.items.length, 2);
	});

	it('treats inline script tags as not isolated modules', async () => {
		const document = await languageServer.openFakeDocument(
			'<script is:inline>const hello = "Hello, Astro!";</script><script is:inline>console.log(hello);</script>',
			'astro',
		);

		const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
			document.uri,
		)) as FullDocumentDiagnosticReport;

		assert.strictEqual(diagnostics.items.length, 0);
	});

	it('still supports script tags with unknown types', async () => {
		const document = await languageServer.openFakeDocument(
			'<script type="something-else">const hello = "Hello, Astro!";</script>',
			'astro',
		);

		const hoverInfo = await languageServer.handle.sendHoverRequest(
			document.uri,
			Position.create(0, 38),
		);

		assert.notStrictEqual(hoverInfo, undefined);
	});

	it('ignores is:raw script tags', async () => {
		const document = await languageServer.openFakeDocument(
			'<script is:raw>const hello = "Hello, Astro!";</script>',
			'astro',
		);

		const hoverInfo = await languageServer.handle.sendHoverRequest(
			document.uri,
			Position.create(0, 38),
		);

		assert.strictEqual(hoverInfo, null);
	});

	it('supports script tags in files with multibytes characters', async () => {
		const document = await languageServer.openFakeDocument(
			`🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
<script>doesntExists</script>`,
			'astro',
		);

		const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest(
			document.uri,
		)) as FullDocumentDiagnosticReport;

		assert.strictEqual(diagnostics.items.length, 1);
		assert.deepStrictEqual(diagnostics.items[0].range, Range.create(1, 8, 1, 20));
	});
});

Domain

Dependencies

Frequently Asked Questions

What does scripts.test.ts do?
scripts.test.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain.
What does scripts.test.ts depend on?
scripts.test.ts imports 5 module(s): getLanguageServer, language-server, node:assert, node:test, server.ts.
Where is scripts.test.ts in the architecture?
scripts.test.ts is located at packages/language-tools/language-server/test/typescript/scripts.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