LiveStyle.TestCase (LiveStyle v0.13.1)

View Source

Base test case for LiveStyle tests.

This module provides a consistent test environment with:

  • Isolated manifest per test (for async test safety)

Usage

defmodule MyTest do
  use LiveStyle.TestCase

  test "example" do
    css = LiveStyle.Compiler.generate_css()
  end
end

How Test Isolation Works

Each test process receives its own copy of the manifest via Storage.fork/0. This ensures:

  1. Tests can modify the manifest without affecting other tests
  2. The shared manifest file remains pristine for module compilation
  3. No race conditions between test execution and test file loading

Options

  • :async - Whether tests can run in parallel (default: true)

Configuration

All LiveStyle configuration is compile-time only (like StyleX's Babel plugin config). Set configuration in config/config.exs or config/test.exs:

config :live_style,
  class_name_prefix: "x",
  use_css_layers: false,
  debug_class_names: true