Home / File/ tsconfig-json-load-error.spec.ts — vite Source File

tsconfig-json-load-error.spec.ts — vite Source File

Architecture documentation for tsconfig-json-load-error.spec.ts, a typescript file in the vite codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  bb44d8bf_6bbb_4d69_abfb_7511a2ea1712["tsconfig-json-load-error.spec.ts"]
  5207a374_7a47_9f47_013b_d15becbef767["serve.ts"]
  bb44d8bf_6bbb_4d69_abfb_7511a2ea1712 --> 5207a374_7a47_9f47_013b_d15becbef767
  bf53f77a_c109_c220_c0da_82dad04b2f6d["clearServeError"]
  bb44d8bf_6bbb_4d69_abfb_7511a2ea1712 --> bf53f77a_c109_c220_c0da_82dad04b2f6d
  a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"]
  bb44d8bf_6bbb_4d69_abfb_7511a2ea1712 --> a340ba46_b2b7_3048_3bb3_6907a74c8464
  d3fd5575_295b_d6be_24dd_62d277645dc9["~utils"]
  bb44d8bf_6bbb_4d69_abfb_7511a2ea1712 --> d3fd5575_295b_d6be_24dd_62d277645dc9
  style bb44d8bf_6bbb_4d69_abfb_7511a2ea1712 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { describe, expect, test } from 'vitest'
import { clearServeError, serveError } from './serve'
import { browserLogs, editFile, isBuild, isServe, page, readFile } from '~utils'

const unexpectedTokenSyntaxErrorRE =
  /(\[vite:esbuild\] )*parsing .* failed: SyntaxError: Unexpected token.*\}.*|Build failed/

describe.runIf(isBuild)('build', () => {
  test('should throw an error on build', () => {
    expect(serveError).toBeTruthy()
    expect(serveError.message).toMatch(unexpectedTokenSyntaxErrorRE)
    clearServeError() // got expected error, null it here so testsuite does not fail from rethrow in afterAll
  })

  test('should not output files to dist', () => {
    let err
    try {
      readFile('dist/index.html')
    } catch (e) {
      err = e
    }
    expect(err).toBeTruthy()
    expect(err.code).toBe('ENOENT')
  })
})

describe.runIf(isServe)('server', () => {
  test('should log 500 error in browser for malformed tsconfig', () => {
    // don't test for actual complete message as this might be locale dependent. chrome does log 500 consistently though
    expect(browserLogs.find((x) => x.includes('500'))).toBeTruthy()
    expect(browserLogs).not.toContain('tsconfig error fixed, file loaded')
  })

  test('should show error overlay for tsconfig error', async () => {
    const errorOverlay = await page.waitForSelector('vite-error-overlay')
    expect(errorOverlay).toBeTruthy()
    const message = await errorOverlay.$$eval('.message-body', (m) => {
      return m[0].innerHTML
    })
    // use regex with variable filename and position values because they are different on win
    expect(message).toMatch(unexpectedTokenSyntaxErrorRE)
  })

  test('should reload when tsconfig is changed', async () => {
    editFile('has-error/tsconfig.json', (content) => {
      return content.replace('"compilerOptions":', '"compilerOptions":{}')
    })
    await expect
      .poll(() => browserLogs)
      .toContain('tsconfig error fixed, file loaded')
  })
})

Domain

Dependencies

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free