Volt.Test.Sigils (Volt v0.15.5)

Copy Markdown View Source

Convenience sigils for JavaScript, TypeScript, JSX, TSX, CSS, and HTML test fixtures.

These sigils are intentionally small: they return normalized source strings for ExUnit tests and examples. Use the optional v modifier to validate JS/TS-like snippets with OXC at runtime.

import Volt.Test.Sigils

source = ~TS"const answer: number = 42"

assert source =~ "answer"

# Validate parser compatibility when the snippet is expected to be valid.
source = ~TS"export const value: string = "ok""v

The multi-letter sigils are intentionally uppercase, which means Elixir does not process escapes or interpolation before the source reaches Volt. This is usually what JS/TS fixtures want.

Summary

Functions

Returns normalized CSS source.

Returns normalized HTML source.

Returns normalized JavaScript source. Use v to validate with OXC.

Returns normalized JSX source. Use v to validate with OXC.

Returns normalized TypeScript source. Use v to validate with OXC.

Returns normalized TSX source. Use v to validate with OXC.

Functions

sigil_CSS(source, modifiers)

Returns normalized CSS source.

sigil_HTML(source, modifiers)

Returns normalized HTML source.

sigil_JS(source, modifiers)

Returns normalized JavaScript source. Use v to validate with OXC.

sigil_JSX(source, modifiers)

Returns normalized JSX source. Use v to validate with OXC.

sigil_TS(source, modifiers)

Returns normalized TypeScript source. Use v to validate with OXC.

sigil_TSX(source, modifiers)

Returns normalized TSX source. Use v to validate with OXC.