Home / File/ test.ts — svelte Source File

test.ts — svelte Source File

Architecture documentation for test.ts, a typescript file in the svelte codebase. 13 imports, 55 dependents.

File typescript BuildSystem MessageProcessor 13 imports 55 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd["test.ts"]
  e97e8c41_1b06_4e9a_29f3_64dbb37dee3c["helpers.js"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> e97e8c41_1b06_4e9a_29f3_64dbb37dee3c
  40a894df_04e7_906d_8c12_9e2e7b588e57["compile_directory"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> 40a894df_04e7_906d_8c12_9e2e7b588e57
  0117e036_4d73_82de_562e_d06d35308ec2["should_update_expected"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> 0117e036_4d73_82de_562e_d06d35308ec2
  2413c72d_083d_061e_c047_c903addfc06e["try_read_file"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> 2413c72d_083d_061e_c047_c903addfc06e
  7e13368c_af2f_099c_e7e1_de404629548f["html_equal.js"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> 7e13368c_af2f_099c_e7e1_de404629548f
  1c541d89_49ad_09df_1b04_218f8bcb99e8["assert_html_equal_with_options"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> 1c541d89_49ad_09df_1b04_218f8bcb99e8
  b2df78f1_f7aa_6fef_0a5c_4dcf959880ff["../suite.js"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> b2df78f1_f7aa_6fef_0a5c_4dcf959880ff
  4440efa2_b84c_d186_53ca_534b0add2937["dev.js"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> 4440efa2_b84c_d186_53ca_534b0add2937
  f596e027_a951_36c9_7695_83acc4f0d6b9["node:fs"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> f596e027_a951_36c9_7695_83acc4f0d6b9
  b63ddb92_634c_990b_eb1b_0bad8a4d434e["vitest"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> b63ddb92_634c_990b_eb1b_0bad8a4d434e
  19c4395f_f4bb_853e_9c49_a71d8228542e["server"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> 19c4395f_f4bb_853e_9c49_a71d8228542e
  c696582a_9f3f_d301_2824_cb3de66aa770["#compiler"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> c696582a_9f3f_d301_2824_cb3de66aa770
  681842b4_5af0_c3ea_17c6_340cc0309def["#server"]
  e19cfbe3_ca82_459d_0cfe_63f6bb4739fd --> 681842b4_5af0_c3ea_17c6_340cc0309def
  768b6043_48a6_30f0_052c_aa95f420bb7c["_config.js"]
  768b6043_48a6_30f0_052c_aa95f420bb7c --> e19cfbe3_ca82_459d_0cfe_63f6bb4739fd
  style e19cfbe3_ca82_459d_0cfe_63f6bb4739fd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// @vitest-environment jsdom

// Yes it's an SSR test, but we need the env to compare html
// TODO: Isolate the html comparison
// TODO: happy-dom might be faster but currently replaces quotes which fails assertions

import * as fs from 'node:fs';
import { assert } from 'vitest';
import { render } from 'svelte/server';
import { compile_directory, should_update_expected, try_read_file } from '../helpers.js';
import { assert_html_equal_with_options } from '../html_equal.js';
import { suite_with_variants, type BaseTest } from '../suite.js';
import type { CompileOptions } from '#compiler';
import { seen } from '../../src/internal/server/dev.js';
import type { SyncRenderOutput } from '#server';

interface SSRTest extends BaseTest {
	mode?: ('sync' | 'async')[];
	compileOptions?: Partial<CompileOptions>;
	load_compiled?: boolean;
	props?: Record<string, any>;
	id_prefix?: string;
	withoutNormalizeHtml?: boolean;
	error?: string;
	csp?: { nonce: string } | { hash: true };
	script_hashes?: string[];
}

// TODO remove this shim when we can
// @ts-expect-error
Promise.withResolvers = () => {
	let resolve;
	let reject;

	const promise = new Promise((f, r) => {
		resolve = f;
		reject = r;
	});

	return { promise, resolve, reject };
};

const { test, run } = suite_with_variants<SSRTest, 'sync' | 'async', CompileOptions>(
	['sync', 'async'],
	(variant, config, test_name) => {
		if (config.mode && !config.mode.includes(variant)) {
			return 'no-test';
		}

		if (test_name.startsWith('async') && variant === 'sync') {
			return 'no-test';
		}

		return false;
	},
	async (config, test_dir) => {
		const compile_options = {
			experimental: {
				async: true,
				...config.compileOptions?.experimental
// ... (100 more lines)

Domain

Subdomains

Functions

Types

Imported By

Frequently Asked Questions

What does test.ts do?
test.ts is a source file in the svelte codebase, written in typescript. It belongs to the BuildSystem domain, MessageProcessor subdomain.
What functions are defined in test.ts?
test.ts defines 1 function(s): Promise.
What does test.ts depend on?
test.ts imports 13 module(s): #compiler, #server, ../suite.js, assert_html_equal_with_options, compile_directory, dev.js, helpers.js, html_equal.js, and 5 more.
What files import test.ts?
test.ts is imported by 55 file(s): _config.js, _config.js, _config.js, _config.js, _config.js, _config.js, _config.js, _config.js, and 47 more.
Where is test.ts in the architecture?
test.ts is located at packages/svelte/tests/server-side-rendering/test.ts (domain: BuildSystem, subdomain: MessageProcessor, directory: packages/svelte/tests/server-side-rendering).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free