Home / File/ test.ts — svelte Source File

test.ts — svelte Source File

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

File typescript BuildSystem MessageProcessor 11 imports 70 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  241c2922_c732_530f_f92d_772220952a6f["test.ts"]
  e97e8c41_1b06_4e9a_29f3_64dbb37dee3c["helpers.js"]
  241c2922_c732_530f_f92d_772220952a6f --> e97e8c41_1b06_4e9a_29f3_64dbb37dee3c
  40a894df_04e7_906d_8c12_9e2e7b588e57["compile_directory"]
  241c2922_c732_530f_f92d_772220952a6f --> 40a894df_04e7_906d_8c12_9e2e7b588e57
  7e13368c_af2f_099c_e7e1_de404629548f["html_equal.js"]
  241c2922_c732_530f_f92d_772220952a6f --> 7e13368c_af2f_099c_e7e1_de404629548f
  3f18e7a4_4010_5e33_35ee_c53c8401ca03["assert_html_equal"]
  241c2922_c732_530f_f92d_772220952a6f --> 3f18e7a4_4010_5e33_35ee_c53c8401ca03
  b2df78f1_f7aa_6fef_0a5c_4dcf959880ff["../suite.js"]
  241c2922_c732_530f_f92d_772220952a6f --> b2df78f1_f7aa_6fef_0a5c_4dcf959880ff
  f596e027_a951_36c9_7695_83acc4f0d6b9["node:fs"]
  241c2922_c732_530f_f92d_772220952a6f --> f596e027_a951_36c9_7695_83acc4f0d6b9
  b63ddb92_634c_990b_eb1b_0bad8a4d434e["vitest"]
  241c2922_c732_530f_f92d_772220952a6f --> b63ddb92_634c_990b_eb1b_0bad8a4d434e
  0089bc1e_86a8_7436_5025_0d4d65a18542["legacy"]
  241c2922_c732_530f_f92d_772220952a6f --> 0089bc1e_86a8_7436_5025_0d4d65a18542
  19c4395f_f4bb_853e_9c49_a71d8228542e["server"]
  241c2922_c732_530f_f92d_772220952a6f --> 19c4395f_f4bb_853e_9c49_a71d8228542e
  c696582a_9f3f_d301_2824_cb3de66aa770["#compiler"]
  241c2922_c732_530f_f92d_772220952a6f --> c696582a_9f3f_d301_2824_cb3de66aa770
  4ead6623_c53e_ab40_5690_64903d5addf1["svelte"]
  241c2922_c732_530f_f92d_772220952a6f --> 4ead6623_c53e_ab40_5690_64903d5addf1
  d29c0fe3_a483_7b0a_8f35_7beb5d332a85["_config.js"]
  d29c0fe3_a483_7b0a_8f35_7beb5d332a85 --> 241c2922_c732_530f_f92d_772220952a6f
  4c8b9bb9_4ec1_7c09_1817_f31f7ff57a81["_config.js"]
  4c8b9bb9_4ec1_7c09_1817_f31f7ff57a81 --> 241c2922_c732_530f_f92d_772220952a6f
  23956161_af26_c087_c660_64f1f969a336["_config.js"]
  23956161_af26_c087_c660_64f1f969a336 --> 241c2922_c732_530f_f92d_772220952a6f
  style 241c2922_c732_530f_f92d_772220952a6f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// @vitest-environment jsdom

import * as fs from 'node:fs';
import { assert } from 'vitest';
import { compile_directory } from '../helpers.js';
import { assert_html_equal } from '../html_equal.js';
import { fragments } from '../helpers.js';
import { assert_ok, suite, type BaseTest } from '../suite.js';
import { createClassComponent } from 'svelte/legacy';
import { render } from 'svelte/server';
import type { CompileOptions } from '#compiler';
import { flushSync } from 'svelte';

interface HydrationTest extends BaseTest {
	load_compiled?: boolean;
	server_props?: Record<string, any>;
	id_prefix?: string;
	props?: Record<string, any>;
	compileOptions?: Partial<CompileOptions>;
	/**
	 * By default, whitespace between ssr comments is removed so the output looks a bit more readable.
	 * Some tests rely on the whitespace being there, so set this to false to disable the removal.
	 */
	trim_whitespace?: false;
	expect_hydration_error?: true;
	snapshot?: (target: HTMLElement) => any;
	test?: (
		assert: typeof import('vitest').assert & {
			htmlEqual(a: string, b: string, description?: string): void;
		},
		target: HTMLElement,
		snapshot: any,
		component: any,
		window: any
	) => void | Promise<void>;
	before_test?: () => void;
	after_test?: () => void;
	errors?: any[];
}

function read(path: string): string | void {
	return fs.existsSync(path) ? fs.readFileSync(path, 'utf-8') : undefined;
}

const { test, run } = suite<HydrationTest>(async (config, cwd) => {
	if (!config.load_compiled) {
		await compile_directory(cwd, 'client', {
			accessors: true,
			fragments,
			...config.compileOptions
		});

		await compile_directory(cwd, 'server', config.compileOptions);
	}

	config.before_test?.();

	const target = window.document.body;
	const head = window.document.head;

// ... (117 more lines)

Domain

Subdomains

Dependencies

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 3 function(s): assert, read, target.
What does test.ts depend on?
test.ts imports 11 module(s): #compiler, ../suite.js, assert_html_equal, compile_directory, helpers.js, html_equal.js, legacy, node:fs, and 3 more.
What files import test.ts?
test.ts is imported by 70 file(s): _config.js, _config.js, _config.js, _config.js, _config.js, _config.js, _config.js, _config.js, and 62 more.
Where is test.ts in the architecture?
test.ts is located at packages/svelte/tests/hydration/test.ts (domain: BuildSystem, subdomain: MessageProcessor, directory: packages/svelte/tests/hydration).

Analyze Your Own Codebase

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

Try Supermodel Free