Home / File/ tests.ts — vite Source File

tests.ts — vite Source File

Architecture documentation for tests.ts, a typescript file in the vite codebase. 7 imports, 2 dependents.

File typescript ViteCore ConfigEngine 7 imports 2 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  c8d9e901_9260_5019_70d1_d0573d544a9c["tests.ts"]
  48f28f67_4a5c_e42b_f942_68d103bdd95b["sass-tests.ts"]
  c8d9e901_9260_5019_70d1_d0573d544a9c --> 48f28f67_4a5c_e42b_f942_68d103bdd95b
  232f303f_2fa9_44e9_cf63_8e94f647770a["sassModuleTests"]
  c8d9e901_9260_5019_70d1_d0573d544a9c --> 232f303f_2fa9_44e9_cf63_8e94f647770a
  94fd8e4d_ae3b_4b48_f334_30785f310a7b["sassOtherTests"]
  c8d9e901_9260_5019_70d1_d0573d544a9c --> 94fd8e4d_ae3b_4b48_f334_30785f310a7b
  c1f2d498_99c4_6a3b_7efe_b6405c4b5604["sassTest"]
  c8d9e901_9260_5019_70d1_d0573d544a9c --> c1f2d498_99c4_6a3b_7efe_b6405c4b5604
  e6032fbc_44cf_58d6_868d_dd15106c18c5["node:fs"]
  c8d9e901_9260_5019_70d1_d0573d544a9c --> e6032fbc_44cf_58d6_868d_dd15106c18c5
  a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"]
  c8d9e901_9260_5019_70d1_d0573d544a9c --> a340ba46_b2b7_3048_3bb3_6907a74c8464
  d3fd5575_295b_d6be_24dd_62d277645dc9["~utils"]
  c8d9e901_9260_5019_70d1_d0573d544a9c --> d3fd5575_295b_d6be_24dd_62d277645dc9
  efd329b8_4040_44b1_2e2b_ac607e135491["css.spec.ts"]
  efd329b8_4040_44b1_2e2b_ac607e135491 --> c8d9e901_9260_5019_70d1_d0573d544a9c
  bbf4bef0_aeaa_5bd8_c9b0_c146f995c2d6["lightningcss.spec.ts"]
  bbf4bef0_aeaa_5bd8_c9b0_c146f995c2d6 --> c8d9e901_9260_5019_70d1_d0573d544a9c
  style c8d9e901_9260_5019_70d1_d0573d544a9c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { readFileSync } from 'node:fs'
import { expect, test } from 'vitest'
import { sassModuleTests, sassOtherTests, sassTest } from './sass-tests'
import {
  editFile,
  findAssetFile,
  getBg,
  getBgColor,
  getColor,
  isBuild,
  page,
  removeFile,
  serverLogs,
  viteTestUrl,
} from '~utils'

export const tests = (isLightningCSS: boolean) => {
  // note: tests should retrieve the element at the beginning of test and reuse it
  // in later assertions to ensure CSS HMR doesn't reload the page
  test('imported css', async () => {
    const glob = await page.textContent('.imported-css-glob')
    expect(glob).toContain('.dir-import')
    const globEager = await page.textContent('.imported-css-globEager')
    expect(globEager).toContain('.dir-import')
  })

  test('linked css', async () => {
    const linked = await page.$('.linked')
    const atImport = await page.$('.linked-at-import')

    expect(await getColor(linked)).toBe('blue')
    expect(await getColor(atImport)).toBe('red')

    if (isBuild) return

    editFile('linked.css', (code) => code.replace('color: blue', 'color: red'))
    await expect.poll(() => getColor(linked)).toBe('red')

    editFile('linked-at-import.css', (code) =>
      code.replace('color: red', 'color: blue'),
    )
    await expect.poll(() => getColor(atImport)).toBe('blue')
  })

  test('css import from js', async () => {
    const imported = await page.$('.imported')
    const atImport = await page.$('.imported-at-import')

    expect(await getColor(imported)).toBe('green')
    expect(await getColor(atImport)).toBe('purple')

    if (isBuild) return

    editFile('imported.css', (code) =>
      code.replace('color: green', 'color: red'),
    )
    await expect.poll(() => getColor(imported)).toBe('red')

    editFile('imported-at-import.css', (code) =>
      code.replace('color: purple', 'color: blue'),
// ... (497 more lines)

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does tests.ts do?
tests.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 tests.ts?
tests.ts defines 1 function(s): tests.
What does tests.ts depend on?
tests.ts imports 7 module(s): node:fs, sass-tests.ts, sassModuleTests, sassOtherTests, sassTest, vitest, ~utils.
What files import tests.ts?
tests.ts is imported by 2 file(s): css.spec.ts, lightningcss.spec.ts.
Where is tests.ts in the architecture?
tests.ts is located at playground/css/__tests__/tests.ts (domain: ViteCore, subdomain: ConfigEngine, directory: playground/css/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free