Home / Function/ setup() — vite Function Reference

setup() — vite Function Reference

Architecture documentation for the setup() function in vitestGlobalSetup.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  b8d3b05d_876d_0bd1_a55f_34a90232c642["setup()"]
  bcb6ec17_e7f0_3af5_0251_1a12e1b52d95["vitestGlobalSetup.ts"]
  b8d3b05d_876d_0bd1_a55f_34a90232c642 -->|defined in| bcb6ec17_e7f0_3af5_0251_1a12e1b52d95
  style b8d3b05d_876d_0bd1_a55f_34a90232c642 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

playground/vitestGlobalSetup.ts lines 9–54

export async function setup({ provide }: TestProject): Promise<void> {
  browserServer = await chromium.launchServer({
    headless: !process.env.VITE_DEBUG_SERVE,
    args: process.env.CI
      ? ['--no-sandbox', '--disable-setuid-sandbox']
      : undefined,
  })

  provide('wsEndpoint', browserServer.wsEndpoint())

  const tempDir = path.resolve(import.meta.dirname, '../playground-temp')
  await fs.rm(tempDir, { recursive: true, force: true })
  await fs.mkdir(tempDir, { recursive: true })
  await fs
    .cp(path.resolve(import.meta.dirname, '../playground'), tempDir, {
      recursive: true,
      dereference: false,
      filter(file) {
        file = file.replace(/\\/g, '/')
        return !file.includes('__tests__') && !/dist(?:\/|$)/.test(file)
      },
    })
    .catch(async (error) => {
      if (error.code === 'EPERM' && error.syscall === 'symlink') {
        throw new Error(
          'Could not create symlinks. On Windows, consider activating Developer Mode to allow non-admin users to create symlinks by following the instructions at https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development.',
        )
      } else {
        throw error
      }
    })
  // also setup dedicated copy for "variant" tests
  for (const [original, variants] of [
    ['assets', ['encoded-base', 'relative-base', 'runtime-base', 'url-base']],
    ['css', ['lightningcss']],
    ['transform-plugin', ['base']],
  ] as const) {
    for (const variant of variants) {
      await fs.cp(
        path.resolve(tempDir, original),
        path.resolve(tempDir, `${original}__${variant}`),
        { recursive: true },
      )
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does setup() do?
setup() is a function in the vite codebase, defined in playground/vitestGlobalSetup.ts.
Where is setup() defined?
setup() is defined in playground/vitestGlobalSetup.ts at line 9.

Analyze Your Own Codebase

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

Try Supermodel Free