Home / File/ ssr-html.spec.ts — vite Source File

ssr-html.spec.ts — vite Source File

Architecture documentation for ssr-html.spec.ts, a typescript file in the vite codebase. 7 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  316b3483_4020_a76f_58c4_860b721dd101["ssr-html.spec.ts"]
  596ebaae_3088_b82e_2732_041785a3fe90["serve.ts"]
  316b3483_4020_a76f_58c4_860b721dd101 --> 596ebaae_3088_b82e_2732_041785a3fe90
  2dd48a01_733b_e717_9c4b_f4fe7eb42567["node:child_process"]
  316b3483_4020_a76f_58c4_860b721dd101 --> 2dd48a01_733b_e717_9c4b_f4fe7eb42567
  10809968_066c_58db_f8b4_cb0464da805e["node:util"]
  316b3483_4020_a76f_58c4_860b721dd101 --> 10809968_066c_58db_f8b4_cb0464da805e
  51e96894_3556_ed5c_1ede_97d449867adf["node:path"]
  316b3483_4020_a76f_58c4_860b721dd101 --> 51e96894_3556_ed5c_1ede_97d449867adf
  6feed3e8_55b8_cce7_b5ef_e40b872585f7["node:url"]
  316b3483_4020_a76f_58c4_860b721dd101 --> 6feed3e8_55b8_cce7_b5ef_e40b872585f7
  a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"]
  316b3483_4020_a76f_58c4_860b721dd101 --> a340ba46_b2b7_3048_3bb3_6907a74c8464
  d3fd5575_295b_d6be_24dd_62d277645dc9["~utils"]
  316b3483_4020_a76f_58c4_860b721dd101 --> d3fd5575_295b_d6be_24dd_62d277645dc9
  style 316b3483_4020_a76f_58c4_860b721dd101 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { execFile } from 'node:child_process'
import { promisify } from 'node:util'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { describe, expect, test } from 'vitest'
import { port } from './serve'
import { editFile, isServe, page } from '~utils'

const url = `http://localhost:${port}`

describe.runIf(isServe)('injected inline scripts', () => {
  test('no injected inline scripts are present', async () => {
    await page.goto(url)
    const inlineScripts = await page.$$eval('script', (nodes) =>
      nodes.filter((n) => !n.getAttribute('src') && n.innerHTML),
    )
    expect(inlineScripts).toHaveLength(0)
  })

  test('injected script proxied correctly', async () => {
    await page.goto(url)
    const proxiedScripts = await page.$$eval('script', (nodes) =>
      nodes
        .filter((n) => {
          const src = n.getAttribute('src')
          if (!src) return false
          return src.includes('?html-proxy&index')
        })
        .map((n) => n.getAttribute('src')),
    )

    // assert at least 1 proxied script exists
    expect(proxiedScripts).not.toHaveLength(0)

    const scriptContents = await Promise.all(
      proxiedScripts.map((src) => fetch(url + src).then((res) => res.text())),
    )

    // all proxied scripts return code
    for (const code of scriptContents) {
      expect(code).toBeTruthy()
    }
  })
})

describe.runIf(isServe)('hmr', () => {
  test('handle virtual module updates', async () => {
    await page.goto(url)
    const el = await page.$('.virtual')
    expect(await el.textContent()).toBe('[success]')

    const loadPromise = page.waitForEvent('load')
    editFile('src/importedVirtual.js', (code) =>
      code.replace('[success]', '[wow]'),
    )
    await loadPromise

    await expect
      .poll(async () => {
        const el = await page.$('.virtual')
// ... (79 more lines)

Domain

Dependencies

  • node:child_process
  • node:path
  • node:url
  • node:util
  • serve.ts
  • vitest
  • ~utils

Frequently Asked Questions

What does ssr-html.spec.ts do?
ssr-html.spec.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain.
What does ssr-html.spec.ts depend on?
ssr-html.spec.ts imports 7 module(s): node:child_process, node:path, node:url, node:util, serve.ts, vitest, ~utils.
Where is ssr-html.spec.ts in the architecture?
ssr-html.spec.ts is located at playground/ssr-html/__tests__/ssr-html.spec.ts (domain: ViteCore, directory: playground/ssr-html/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free