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

dev.spec.ts — vite Source File

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

Entity Profile

Dependency Diagram

graph LR
  b126a12b_207a_1dea_fbf4_d8a321104f39["dev.spec.ts"]
  abfc9e70_3c15_b3f0_a595_3cf27afb7e64["utils.ts"]
  b126a12b_207a_1dea_fbf4_d8a321104f39 --> abfc9e70_3c15_b3f0_a595_3cf27afb7e64
  5b95806c_6cb8_a9a6_1dd6_709fd3849415["promiseWithResolvers"]
  b126a12b_207a_1dea_fbf4_d8a321104f39 --> 5b95806c_6cb8_a9a6_1dd6_709fd3849415
  a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"]
  b126a12b_207a_1dea_fbf4_d8a321104f39 --> a340ba46_b2b7_3048_3bb3_6907a74c8464
  54c37fea_4fe7_2693_71cb_1276b77f55f9["vite"]
  b126a12b_207a_1dea_fbf4_d8a321104f39 --> 54c37fea_4fe7_2693_71cb_1276b77f55f9
  2616bf8c_8895_7af5_fb6e_8424b9e71ea7[".."]
  b126a12b_207a_1dea_fbf4_d8a321104f39 --> 2616bf8c_8895_7af5_fb6e_8424b9e71ea7
  style b126a12b_207a_1dea_fbf4_d8a321104f39 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { afterEach, describe, expect, test } from 'vitest'
import type { ResolvedServerUrls } from 'vite'
import { createServer, resolveConfig } from '..'
import type { ViteDevServer } from '..'
import { promiseWithResolvers } from '../../shared/utils'

describe('resolveBuildEnvironmentOptions in dev', () => {
  test('build.rollupOptions should not have input in lib', async () => {
    const config = await resolveConfig(
      {
        build: {
          lib: {
            entry: './index.js',
          },
        },
      },
      'serve',
    )

    expect(config.build.rollupOptions).not.toHaveProperty('input')
  })
})

describe('the dev server', () => {
  let server: ViteDevServer

  afterEach(async () => {
    await server?.close()
  })

  test('resolves the server URLs before the httpServer listening events are called', async () => {
    expect.assertions(1)

    const options = {
      port: 5013, // make sure the port is unique
    }

    const { promise, resolve } =
      promiseWithResolvers<ResolvedServerUrls | null>()
    server = await createServer({
      root: import.meta.dirname,
      logLevel: 'error',
      server: {
        strictPort: true,
        ws: false,
        ...options,
      },
      plugins: [
        {
          name: 'test',
          configureServer(server) {
            server.httpServer?.on('listening', () => {
              resolve(server.resolvedUrls)
            })
          },
        },
      ],
    })

    await server.listen()
    const urls = await promise

    expect(urls).toStrictEqual({
      local: ['http://localhost:5013/'],
      network: [],
    })
  })
})

Domain

Dependencies

Frequently Asked Questions

What does dev.spec.ts do?
dev.spec.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain.
What does dev.spec.ts depend on?
dev.spec.ts imports 5 module(s): .., promiseWithResolvers, utils.ts, vite, vitest.
Where is dev.spec.ts in the architecture?
dev.spec.ts is located at packages/vite/src/node/__tests__/dev.spec.ts (domain: ViteCore, directory: packages/vite/src/node/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free