Home / File/ css.spec.ts — vite Source File

css.spec.ts — vite Source File

Architecture documentation for css.spec.ts, a typescript file in the vite codebase. 4 imports, 0 dependents.

File typescript 4 imports

Entity Profile

Dependency Diagram

graph LR
  c42953cf_eb08_5d0b_3667_a3d83a22cf39["css.spec.ts"]
  51e96894_3556_ed5c_1ede_97d449867adf["node:path"]
  c42953cf_eb08_5d0b_3667_a3d83a22cf39 --> 51e96894_3556_ed5c_1ede_97d449867adf
  54c37fea_4fe7_2693_71cb_1276b77f55f9["vite"]
  c42953cf_eb08_5d0b_3667_a3d83a22cf39 --> 54c37fea_4fe7_2693_71cb_1276b77f55f9
  a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"]
  c42953cf_eb08_5d0b_3667_a3d83a22cf39 --> a340ba46_b2b7_3048_3bb3_6907a74c8464
  d3fd5575_295b_d6be_24dd_62d277645dc9["~utils"]
  c42953cf_eb08_5d0b_3667_a3d83a22cf39 --> d3fd5575_295b_d6be_24dd_62d277645dc9
  style c42953cf_eb08_5d0b_3667_a3d83a22cf39 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import path from 'node:path'
import { createServer } from 'vite'
import { expect, test } from 'vitest'
import { getColor, isServe, page, ports } from '~utils'

test.runIf(isServe)('postcss config', async () => {
  const port = ports['css/postcss-caching']
  const startServer = async (root) => {
    const server = await createServer({
      root,
      logLevel: 'silent',
      server: {
        port,
        strictPort: true,
      },
      build: {
        // skip transpilation during tests to make it faster
        target: 'esnext',
      },
    })
    await server.listen()
    return server
  }

  const blueAppDir = path.join(import.meta.dirname, 'blue-app')
  const greenAppDir = path.join(import.meta.dirname, 'green-app')
  let blueApp
  let greenApp
  try {
    const hmrConnectionPromise = page.waitForEvent('console', (msg) =>
      msg.text().includes('connected'),
    )

    blueApp = await startServer(blueAppDir)

    await page.goto(`http://localhost:${port}`, { waitUntil: 'load' })
    const blueA = await page.$('.postcss-a')
    expect(await getColor(blueA)).toBe('blue')
    const blueB = await page.$('.postcss-b')
    expect(await getColor(blueB)).toBe('black')

    // wait for hmr connection because: if server stops before connection, auto reload does not happen
    await hmrConnectionPromise
    await blueApp.close()
    blueApp = null

    const loadPromise = page.waitForEvent('load') // wait for server restart auto reload
    greenApp = await startServer(greenAppDir)
    await loadPromise

    const greenA = await page.$('.postcss-a')
    expect(await getColor(greenA)).toBe('black')
    const greenB = await page.$('.postcss-b')
    expect(await getColor(greenB)).toBe('green')
    await greenApp.close()
    greenApp = null
  } finally {
    if (blueApp) {
      await blueApp.close()
    }
    if (greenApp) {
      await greenApp.close()
    }
  }
})

Dependencies

  • node:path
  • vite
  • vitest
  • ~utils

Frequently Asked Questions

What does css.spec.ts do?
css.spec.ts is a source file in the vite codebase, written in typescript.
What does css.spec.ts depend on?
css.spec.ts imports 4 module(s): node:path, vite, vitest, ~utils.
Where is css.spec.ts in the architecture?
css.spec.ts is located at playground/css/postcss-caching/css.spec.ts (directory: playground/css/postcss-caching).

Analyze Your Own Codebase

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

Try Supermodel Free