htmlctest

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package htmlctest provides helpers for testing htmlc components.

It is intended for use in *_test.go files. The helpers reduce the boilerplate of creating an in-memory filesystem, wiring up an Engine, and asserting on rendered HTML output.

Example:

func TestGreeting(t *testing.T) {
    e := htmlctest.NewEngine(t, map[string]string{
        "Greeting.vue": `<template><p>Hello {{ name }}!</p></template>`,
    })
    htmlctest.AssertFragment(t, e, "Greeting",
        map[string]any{"name": "World"},
        "<p>Hello World!</p>",
    )
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertFragment

func AssertFragment(t testing.TB, e *htmlc.Engine, name string, data map[string]any, want string)

AssertFragment asserts that rendering name as an HTML fragment with data produces HTML equal to want (after normalising whitespace).

func AssertRendersHTML

func AssertRendersHTML(t testing.TB, e *htmlc.Engine, name string, data map[string]any, want string)

AssertRendersHTML asserts that rendering name as a full HTML page with data produces HTML equal to want (after normalising whitespace).

func NewEngine

func NewEngine(t testing.TB, files map[string]string, opts ...htmlc.Options) *htmlc.Engine

NewEngine creates a test Engine backed by an in-memory filesystem built from files. The keys of files are file paths (e.g. "Button.vue") and the values are their contents.

If any option is provided via opts it replaces the default Options; the FS and ComponentDir fields are always overridden by the in-memory filesystem.

t.Cleanup is registered to satisfy the testing.TB contract; no goroutines are started so there is nothing to clean up at this time — the hook is reserved for future use.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL