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

cli.spec.ts — vite Source File

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

import { expect, test } from 'vitest'
import { port, streams } from './serve'
import { editFile, isServe, page } from '~utils'

test('cli should work', async () => {
  // this test uses a custom serve implementation, so regular helpers for browserLogs and goto don't work
  // do the same thing manually
  const logs = []
  const onConsole = (msg) => {
    logs.push(msg.text())
  }
  try {
    page.on('console', onConsole)
    await page.goto(`http://localhost:${port}/`)

    expect(await page.textContent('.app')).toBe('vite cli works!')
    expect(logs.some((msg) => msg.match('vite cli works!'))).toBe(true)
  } finally {
    page.off('console', onConsole)
  }
})

test.runIf(isServe)('should restart', async () => {
  const logsLengthBeforeEdit = streams.server.out.length
  editFile('./vite.config.js', (content) => content)
  await expect
    .poll(() => {
      const logs = streams.server.out.slice(logsLengthBeforeEdit)
      expect(logs).toEqual(
        expect.arrayContaining([expect.stringMatching('server restarted')]),
      )
      // Don't reprint the server URLs as they are the same
      expect(logs).not.toEqual(
        expect.arrayContaining([expect.stringMatching('http://localhost')]),
      )
      expect(logs).not.toEqual(
        expect.arrayContaining([expect.stringMatching('error')]),
      )
    })
    .toSatisfy(() => true)
})

Domain

Dependencies

Frequently Asked Questions

What does cli.spec.ts do?
cli.spec.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain.
What does cli.spec.ts depend on?
cli.spec.ts imports 3 module(s): serve.ts, vitest, ~utils.
Where is cli.spec.ts in the architecture?
cli.spec.ts is located at playground/cli/__tests__/cli.spec.ts (domain: ViteCore, directory: playground/cli/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free