Caravela.Gen.SvelteTest (Caravela v0.13.2)

Copy Markdown View Source

Generates Vitest + @testing-library/svelte smoke tests — one *.test.ts file colocated next to every generated Svelte component. The tests assert the component mounts with minimally valid props and exposes key entity fields in the DOM. They are deliberately thin — a CI oracle that catches "my prop contract changed and the component now throws", not a full UX regression suite.

Consumer apps need vitest and @testing-library/svelte as dev-dependencies. Caravela's generated package.json entries (shipped as documentation in v0.12+) pin compatible versions.

Returns a list of {path, source} tuples.

Summary

Functions

Generate a Vitest file per Svelte component kind per entity.

Colocated test-file path next to the generated Svelte file.

Functions

render_all(domain, opts \\ [])

@spec render_all(
  Caravela.Schema.Domain.t(),
  keyword()
) :: [{String.t(), String.t()}]

Generate a Vitest file per Svelte component kind per entity.

render_component(domain, entity, kind, opts \\ [])

@spec render_component(
  Caravela.Schema.Domain.t(),
  Caravela.Schema.Entity.t(),
  :index | :show | :form,
  keyword()
) :: {String.t(), String.t()}

Generate a single test file.

test_file_path(domain, entity, kind)

@spec test_file_path(
  Caravela.Schema.Domain.t(),
  Caravela.Schema.Entity.t(),
  :index | :show | :form
) ::
  String.t()

Colocated test-file path next to the generated Svelte file.