Home / File/ test-utils.ts — vite Source File

test-utils.ts — vite Source File

Architecture documentation for test-utils.ts, a typescript file in the vite codebase. 9 imports, 0 dependents.

File typescript ViteCore ConfigEngine 9 imports 23 functions

Entity Profile

Dependency Diagram

graph LR
  c68b21f4_9cd3_3abe_8169_0de2c9650f53["test-utils.ts"]
  804dc5f9_3eef_472e_8575_1233b4358f17["vitestSetup.ts"]
  c68b21f4_9cd3_3abe_8169_0de2c9650f53 --> 804dc5f9_3eef_472e_8575_1233b4358f17
  e6032fbc_44cf_58d6_868d_dd15106c18c5["node:fs"]
  c68b21f4_9cd3_3abe_8169_0de2c9650f53 --> e6032fbc_44cf_58d6_868d_dd15106c18c5
  51e96894_3556_ed5c_1ede_97d449867adf["node:path"]
  c68b21f4_9cd3_3abe_8169_0de2c9650f53 --> 51e96894_3556_ed5c_1ede_97d449867adf
  5a419bd6_0410_fe69_efea_c1d2dee2bd10["css-color-names"]
  c68b21f4_9cd3_3abe_8169_0de2c9650f53 --> 5a419bd6_0410_fe69_efea_c1d2dee2bd10
  daea26b3_da11_dee8_9ffd_9dbc0e857906["playwright-chromium"]
  c68b21f4_9cd3_3abe_8169_0de2c9650f53 --> daea26b3_da11_dee8_9ffd_9dbc0e857906
  54c37fea_4fe7_2693_71cb_1276b77f55f9["vite"]
  c68b21f4_9cd3_3abe_8169_0de2c9650f53 --> 54c37fea_4fe7_2693_71cb_1276b77f55f9
  dc6f5c19_97fd_e1d7_2ae6_6a0d69e562e6["convert-source-map"]
  c68b21f4_9cd3_3abe_8169_0de2c9650f53 --> dc6f5c19_97fd_e1d7_2ae6_6a0d69e562e6
  a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"]
  c68b21f4_9cd3_3abe_8169_0de2c9650f53 --> a340ba46_b2b7_3048_3bb3_6907a74c8464
  e4bc57e8_546b_c84b_ee54_df323bec2a01["execa"]
  c68b21f4_9cd3_3abe_8169_0de2c9650f53 --> e4bc57e8_546b_c84b_ee54_df323bec2a01
  style c68b21f4_9cd3_3abe_8169_0de2c9650f53 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// test utils used in e2e tests for playgrounds.
// `import { getColor } from '~utils'`

import fs from 'node:fs'
import path from 'node:path'
import colors from 'css-color-names'
import type {
  ConsoleMessage,
  ElementHandle,
  Locator,
} from 'playwright-chromium'
import type { DepOptimizationMetadata, Manifest } from 'vite'
import { normalizePath } from 'vite'
import { fromComment, removeComments } from 'convert-source-map'
import { expect } from 'vitest'
import type { ResultPromise as ExecaResultPromise } from 'execa'
import { isWindows, page, sourcemapSnapshot, testDir } from './vitestSetup'

export * from './vitestSetup'

// make sure these ports are unique
export const ports = {
  cli: 9510,
  'cli-module': 9511,
  json: 9512,
  'legacy/ssr': 9520,
  lib: 9521,
  'optimize-missing-deps': 9522,
  'legacy/client-and-ssr': 9523,
  'assets/encoded-base': 9554, // not imported but used in `assets/vite.config-encoded-base.js`
  'assets/url-base': 9525, // not imported but used in `assets/vite.config-url-base.js`
  ssr: 9600,
  'ssr-deps': 9601,
  'ssr-html': 9602,
  'ssr-noexternal': 9603,
  'ssr-pug': 9604,
  'ssr-wasm': 9608,
  'ssr-webworker': 9605,
  'proxy-bypass': 9606, // not imported but used in `proxy-hmr/vite.config.js`
  'proxy-bypass/non-existent-app': 9607, // not imported but used in `proxy-hmr/other-app/vite.config.js`
  'ssr-hmr': 9609, // not imported but used in `hmr-ssr/__tests__/hmr.spec.ts`
  'proxy-hmr': 9616, // not imported but used in `proxy-hmr/vite.config.js`
  'proxy-hmr/other-app': 9617, // not imported but used in `proxy-hmr/other-app/vite.config.js`
  'ssr-conditions': 9620,
  'css/postcss-caching': 5005,
  'css/postcss-plugins-different-dir': 5006,
  'css/dynamic-import': 5007,
  'css/lightningcss-proxy': 5008,
  'backend-integration': 5009,
  'client-reload': 5010,
  'client-reload/hmr-port': 5011,
  'client-reload/cross-origin': 5012,
}
export const hmrPorts = {
  'optimize-missing-deps': 24680,
  ssr: 24681,
  'ssr-deps': 24682,
  'ssr-html': 24683,
  'ssr-noexternal': 24684,
  'ssr-pug': 24685,
// ... (350 more lines)

Domain

Subdomains

Dependencies

  • convert-source-map
  • css-color-names
  • execa
  • node:fs
  • node:path
  • playwright-chromium
  • vite
  • vitest
  • vitestSetup.ts

Frequently Asked Questions

What does test-utils.ts do?
test-utils.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain, ConfigEngine subdomain.
What functions are defined in test-utils.ts?
test-utils.ts defines 23 function(s): addFile, componentToHex, editFile, extractSourcemap, findAssetFile, formatSourcemapForSnapshot, getBg, getBgColor, getColor, killProcess, and 13 more.
What does test-utils.ts depend on?
test-utils.ts imports 9 module(s): convert-source-map, css-color-names, execa, node:fs, node:path, playwright-chromium, vite, vitest, and 1 more.
Where is test-utils.ts in the architecture?
test-utils.ts is located at playground/test-utils.ts (domain: ViteCore, subdomain: ConfigEngine, directory: playground).

Analyze Your Own Codebase

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

Try Supermodel Free