Home / File/ init.test.ts — ui Source File

init.test.ts — ui Source File

Architecture documentation for init.test.ts, a typescript file in the ui codebase. 9 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  850315ae_10e7_b3da_fe0a_07bc60ae8665["init.test.ts"]
  d74412ab_0ee4_22df_d4c9_26e6c03c4a41["helpers.ts"]
  850315ae_10e7_b3da_fe0a_07bc60ae8665 --> d74412ab_0ee4_22df_d4c9_26e6c03c4a41
  7cd02b67_26ab_6129_7de6_8ec39df1ad51["createFixtureTestDirectory"]
  850315ae_10e7_b3da_fe0a_07bc60ae8665 --> 7cd02b67_26ab_6129_7de6_8ec39df1ad51
  e064366d_d787_111b_590e_d9ec019cc193["cssHasProperties"]
  850315ae_10e7_b3da_fe0a_07bc60ae8665 --> e064366d_d787_111b_590e_d9ec019cc193
  26ee316c_482d_d5d0_7c05_26095f85f089["npxShadcn"]
  850315ae_10e7_b3da_fe0a_07bc60ae8665 --> 26ee316c_482d_d5d0_7c05_26095f85f089
  36b31cf1_05ba_97d7_e250_f336253a3080["registry.ts"]
  850315ae_10e7_b3da_fe0a_07bc60ae8665 --> 36b31cf1_05ba_97d7_e250_f336253a3080
  a0458d14_2934_bf61_05f7_fa8e1ffcf6c9["createRegistryServer"]
  850315ae_10e7_b3da_fe0a_07bc60ae8665 --> a0458d14_2934_bf61_05f7_fa8e1ffcf6c9
  d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"]
  850315ae_10e7_b3da_fe0a_07bc60ae8665 --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5
  f9f5e551_eb59_1a6b_8bf2_b97e73eb13de["fs-extra"]
  850315ae_10e7_b3da_fe0a_07bc60ae8665 --> f9f5e551_eb59_1a6b_8bf2_b97e73eb13de
  c8d55bee_7008_1e1f_317b_8dc47b31b6a8["vitest"]
  850315ae_10e7_b3da_fe0a_07bc60ae8665 --> c8d55bee_7008_1e1f_317b_8dc47b31b6a8
  style 850315ae_10e7_b3da_fe0a_07bc60ae8665 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import path from "path"
import fs from "fs-extra"
import { describe, expect, it } from "vitest"

import {
  createFixtureTestDirectory,
  cssHasProperties,
  npxShadcn,
} from "../utils/helpers"
import { createRegistryServer } from "../utils/registry"

describe("shadcn init - next-app", () => {
  it("should init with default configuration", async () => {
    // Sleep for 1 second to avoid race condition with the registry server.
    await new Promise((resolve) => setTimeout(resolve, 2000))

    const fixturePath = await createFixtureTestDirectory("next-app")
    await npxShadcn(fixturePath, ["init", "--base-color=neutral"])

    const componentsJsonPath = path.join(fixturePath, "components.json")
    expect(await fs.pathExists(componentsJsonPath)).toBe(true)

    const componentsJson = await fs.readJson(componentsJsonPath)
    expect(componentsJson).toMatchObject({
      style: "new-york",
      rsc: true,
      tsx: true,
      tailwind: {
        config: "",
        css: "app/globals.css",
        baseColor: "neutral",
        cssVariables: true,
      },
      aliases: {
        components: "@/components",
        utils: "@/lib/utils",
        ui: "@/components/ui",
        lib: "@/lib",
        hooks: "@/hooks",
      },
    })

    expect(await fs.pathExists(path.join(fixturePath, "lib/utils.ts"))).toBe(
      true
    )

    const cssPath = path.join(fixturePath, "app/globals.css")
    const cssContent = await fs.readFile(cssPath, "utf-8")
    expect(cssContent).toContain("@layer base")
    expect(cssContent).toContain(":root")
    expect(cssContent).toContain(".dark")
    expect(cssContent).toContain("tw-animate-css")
    expect(cssContent).toContain("--background")
    expect(cssContent).toContain("--foreground")
  })

  it("should init with custom base color", async () => {
    const fixturePath = await createFixtureTestDirectory("next-app")
    await npxShadcn(fixturePath, ["init", "--base-color=zinc"])

// ... (496 more lines)

Frequently Asked Questions

What does init.test.ts do?
init.test.ts is a source file in the ui codebase, written in typescript. It belongs to the ComponentRegistry domain.
What does init.test.ts depend on?
init.test.ts imports 9 module(s): createFixtureTestDirectory, createRegistryServer, cssHasProperties, fs-extra, helpers.ts, npxShadcn, path, registry.ts, and 1 more.
Where is init.test.ts in the architecture?
init.test.ts is located at packages/tests/src/tests/init.test.ts (domain: ComponentRegistry, directory: packages/tests/src/tests).

Analyze Your Own Codebase

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

Try Supermodel Free