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

html.spec.ts — vite Source File

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

File typescript ViteCore ConfigEngine 2 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  d083ed5a_4f44_e5b1_db04_19687512a74b["html.spec.ts"]
  a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"]
  d083ed5a_4f44_e5b1_db04_19687512a74b --> a340ba46_b2b7_3048_3bb3_6907a74c8464
  d3fd5575_295b_d6be_24dd_62d277645dc9["~utils"]
  d083ed5a_4f44_e5b1_db04_19687512a74b --> d3fd5575_295b_d6be_24dd_62d277645dc9
  style d083ed5a_4f44_e5b1_db04_19687512a74b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { beforeAll, describe, expect, test } from 'vitest'
import {
  browserLogs,
  editFile,
  getColor,
  isBuild,
  isServe,
  page,
  serverLogs,
  untilBrowserLogAfter,
  viteServer,
  viteTestUrl,
} from '~utils'

function fetchHtml(p: string) {
  return fetch(viteTestUrl + p, {
    headers: { Accept: 'text/html,*/*' },
  })
}

function testPage(isNested: boolean) {
  test('pre transform', async () => {
    expect(await page.$('head meta[name=viewport]')).toBeTruthy()
  })

  test('string transform', async () => {
    expect(await page.textContent('h1')).toBe(
      isNested ? 'Nested' : 'Transformed',
    )
  })

  test('tags transform', async () => {
    const el = await page.$('head meta[name=description]')
    expect(await el.getAttribute('content')).toBe('a vite app')

    const kw = await page.$('head meta[name=keywords]')
    expect(await kw.getAttribute('content')).toBe('es modules')
  })

  test('combined transform', async () => {
    expect(await page.title()).toBe('Test HTML transforms')
    // the p should be injected to body
    expect(await page.textContent('body p.inject')).toBe('This is injected')
  })

  test('server only transform', async () => {
    if (!isBuild) {
      expect(await page.textContent('body p.server')).toMatch(
        'injected only during dev',
      )
    } else {
      expect(await page.innerHTML('body')).not.toMatch('p class="server"')
    }
  })

  test('build only transform', async () => {
    if (isBuild) {
      expect(await page.textContent('body p.build')).toMatch(
        'injected only during build',
      )
// ... (486 more lines)

Domain

Subdomains

Dependencies

  • vitest
  • ~utils

Frequently Asked Questions

What does html.spec.ts do?
html.spec.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 html.spec.ts?
html.spec.ts defines 2 function(s): fetchHtml, testPage.
What does html.spec.ts depend on?
html.spec.ts imports 2 module(s): vitest, ~utils.
Where is html.spec.ts in the architecture?
html.spec.ts is located at playground/html/__tests__/html.spec.ts (domain: ViteCore, subdomain: ConfigEngine, directory: playground/html/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free