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

assets.spec.ts — vite Source File

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

File typescript ViteCore ConfigEngine 3 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  2935a7c0_0a03_1922_7738_100becdf4d1f["assets.spec.ts"]
  51e96894_3556_ed5c_1ede_97d449867adf["node:path"]
  2935a7c0_0a03_1922_7738_100becdf4d1f --> 51e96894_3556_ed5c_1ede_97d449867adf
  a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"]
  2935a7c0_0a03_1922_7738_100becdf4d1f --> a340ba46_b2b7_3048_3bb3_6907a74c8464
  d3fd5575_295b_d6be_24dd_62d277645dc9["~utils"]
  2935a7c0_0a03_1922_7738_100becdf4d1f --> d3fd5575_295b_d6be_24dd_62d277645dc9
  style 2935a7c0_0a03_1922_7738_100becdf4d1f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import path from 'node:path'
import { describe, expect, test } from 'vitest'
import {
  browserLogs,
  editFile,
  findAssetFile,
  getBg,
  getColor,
  isBuild,
  isServe,
  listAssets,
  notifyRebuildComplete,
  page,
  readFile,
  readManifest,
  serverLogs,
  viteTestUrl,
  watcher,
} from '~utils'

const assetMatch = isBuild
  ? /\/foo\/bar\/assets\/asset-[-\w]{8}\.png/
  : '/foo/bar/nested/asset.png'

const encodedAssetMatch = isBuild
  ? /\/foo\/bar\/assets\/asset_small_-[-\w]{8}\.png/
  : '/foo/bar/nested/asset[small].png'

const iconMatch = `/foo/bar/icon.png`

const fetchPath = (p: string) => {
  return fetch(path.posix.join(viteTestUrl, p), {
    headers: { Accept: 'text/html,*/*' },
  })
}

test('should have no 404s', () => {
  browserLogs.forEach((msg) => {
    expect(msg).not.toMatch('404')
  })
})

test.runIf(isBuild)(
  'should not warn about VITE_ASSET tokens in image-set',
  async () => {
    expect(serverLogs).toStrictEqual(
      expect.not.arrayContaining([
        expect.stringMatching(/VITE_ASSET__.*?didn't resolve at build time/),
      ]),
    )
  },
)

test('should get a 404 when using incorrect case', async () => {
  expect((await fetchPath('icon.png')).headers.get('Content-Type')).toBe(
    'image/png',
  )
  // fallback to index.html
  const iconPngResult = await fetchPath('ICON.png')
  expect(iconPngResult.headers.get('Content-Type')).toBe('text/html')
// ... (718 more lines)

Domain

Subdomains

Functions

Dependencies

  • node:path
  • vitest
  • ~utils

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free