Home / File/ test.ts — svelte Source File

test.ts — svelte Source File

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

File typescript BuildSystem 6 imports 19 dependents

Entity Profile

Dependency Diagram

graph LR
  406097f0_d86f_385c_81a3_85c1d8e5f488["test.ts"]
  e97e8c41_1b06_4e9a_29f3_64dbb37dee3c["helpers.js"]
  406097f0_d86f_385c_81a3_85c1d8e5f488 --> e97e8c41_1b06_4e9a_29f3_64dbb37dee3c
  2413c72d_083d_061e_c047_c903addfc06e["try_read_file"]
  406097f0_d86f_385c_81a3_85c1d8e5f488 --> 2413c72d_083d_061e_c047_c903addfc06e
  b2df78f1_f7aa_6fef_0a5c_4dcf959880ff["../suite.js"]
  406097f0_d86f_385c_81a3_85c1d8e5f488 --> b2df78f1_f7aa_6fef_0a5c_4dcf959880ff
  f596e027_a951_36c9_7695_83acc4f0d6b9["node:fs"]
  406097f0_d86f_385c_81a3_85c1d8e5f488 --> f596e027_a951_36c9_7695_83acc4f0d6b9
  b63ddb92_634c_990b_eb1b_0bad8a4d434e["vitest"]
  406097f0_d86f_385c_81a3_85c1d8e5f488 --> b63ddb92_634c_990b_eb1b_0bad8a4d434e
  a8d49317_f479_a216_78e7_48c9e32499d5["compiler"]
  406097f0_d86f_385c_81a3_85c1d8e5f488 --> a8d49317_f479_a216_78e7_48c9e32499d5
  4449a3f8_994e_90e1_a2e3_9bb967912782["_config.js"]
  4449a3f8_994e_90e1_a2e3_9bb967912782 --> 406097f0_d86f_385c_81a3_85c1d8e5f488
  92cd495a_d105_1815_407f_cc1aaaae1a29["_config.js"]
  92cd495a_d105_1815_407f_cc1aaaae1a29 --> 406097f0_d86f_385c_81a3_85c1d8e5f488
  aefd6889_6b65_dbf1_01e5_0374469eb131["_config.js"]
  aefd6889_6b65_dbf1_01e5_0374469eb131 --> 406097f0_d86f_385c_81a3_85c1d8e5f488
  14996555_4887_7763_ca6f_8bee439cb3ca["_config.js"]
  14996555_4887_7763_ca6f_8bee439cb3ca --> 406097f0_d86f_385c_81a3_85c1d8e5f488
  920bdcbc_153d_0dca_4b4c_00b26878e68a["_config.js"]
  920bdcbc_153d_0dca_4b4c_00b26878e68a --> 406097f0_d86f_385c_81a3_85c1d8e5f488
  4b3de9ee_9945_cc13_2b2f_ff2e26d05b41["_config.js"]
  4b3de9ee_9945_cc13_2b2f_ff2e26d05b41 --> 406097f0_d86f_385c_81a3_85c1d8e5f488
  d5145b5d_dc85_2c31_ee11_469a60ee3cd0["_config.js"]
  d5145b5d_dc85_2c31_ee11_469a60ee3cd0 --> 406097f0_d86f_385c_81a3_85c1d8e5f488
  8a7e750b_de49_91e3_462c_ab323139db60["_config.js"]
  8a7e750b_de49_91e3_462c_ab323139db60 --> 406097f0_d86f_385c_81a3_85c1d8e5f488
  style 406097f0_d86f_385c_81a3_85c1d8e5f488 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as fs from 'node:fs';
import { assert } from 'vitest';
import { migrate } from 'svelte/compiler';
import { try_read_file } from '../helpers.js';
import { suite, type BaseTest } from '../suite.js';

interface ParserTest extends BaseTest {
	skip_filename?: boolean;
	use_ts?: boolean;
	logs?: any[];
	errors?: any[];
}

const { test, run } = suite<ParserTest>(async (config, cwd) => {
	const input = fs
		.readFileSync(`${cwd}/input.svelte`, 'utf-8')
		.replace(/\s+$/, '')
		.replace(/\r/g, '');

	const logs: any[] = [];
	const errors: any[] = [];

	if (config.logs) {
		console.log = (...args) => {
			logs.push(...args);
		};
	}

	if (config.errors) {
		console.error = (...args) => {
			errors.push(...args.map((arg) => arg.toJSON?.() ?? arg));
		};
	}

	const actual = migrate(input, {
		filename: config.skip_filename ? undefined : `output.svelte`,
		use_ts: config.use_ts
	}).code;

	if (config.logs) {
		assert.deepEqual(logs, config.logs);
	}

	if (config.errors) {
		assert.deepEqual(errors, config.errors);
	}

	// run `UPDATE_SNAPSHOTS=true pnpm test migrate` to update parser tests
	if (process.env.UPDATE_SNAPSHOTS || !fs.existsSync(`${cwd}/output.svelte`)) {
		fs.writeFileSync(`${cwd}/output.svelte`, actual);
	} else {
		fs.writeFileSync(`${cwd}/_actual.svelte`, actual);

		const expected = try_read_file(`${cwd}/output.svelte`);
		assert.deepEqual(actual.trim(), expected?.trim());
	}
});

export { test };

await run(__dirname);

Domain

Types

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.
What does test.ts depend on?
test.ts imports 6 module(s): ../suite.js, compiler, helpers.js, node:fs, try_read_file, vitest.
What files import test.ts?
test.ts is imported by 19 file(s): _config.js, _config.js, _config.js, _config.js, _config.js, _config.js, _config.js, _config.js, and 11 more.
Where is test.ts in the architecture?
test.ts is located at packages/svelte/tests/migrate/test.ts (domain: BuildSystem, directory: packages/svelte/tests/migrate).

Analyze Your Own Codebase

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

Try Supermodel Free