https://github.com/survivorbat/huhtest
huhtest is a work-in-progress test library for your huh forms
https://github.com/survivorbat/huhtest
cli cobra command go golang huh huhtest stdin stdout test unit unittest
Last synced: about 2 months ago
JSON representation
huhtest is a work-in-progress test library for your huh forms
- Host: GitHub
- URL: https://github.com/survivorbat/huhtest
- Owner: survivorbat
- License: mit
- Created: 2024-07-12T18:52:22.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-10T17:46:38.000Z (8 months ago)
- Last Synced: 2025-05-31T03:29:42.940Z (5 months ago)
- Topics: cli, cobra, command, go, golang, huh, huhtest, stdin, stdout, test, unit, unittest
- Language: Go
- Homepage: https://pkg.go.dev/github.com/survivorbat/huhtest
- Size: 23.4 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ค Huh Test
`huhtest` is a work-in-progress test library for your [huh](https://github.com/charmbracelet/huh) forms.
If you're - for some reason - eager to test your huh-based interactive CLI applications then you've come to
the right place.
It works by matching messages in a form's output (stdout) and then sending pre-programmed text to the form's input (stdin).
It's not 100% bug-free, as some combinations of groups and selects seem to have off-by-one errors.
## โฌ๏ธ Installation
`go get github.com/survivorbat/huhtest`
## ๐ Usage
Check out [this example](./examples_test.go)
## ๐งช Testing
To make sure this thing actually works, we have both unit tests and integration tests, the former
checks the output of `huhtest` directly, the latter actually uses `huh` to check whether the inputs
are properly processed.
## ๐ Debugging
There's a `.Debug()` method available that enabled extra logging in the `Responser`. If you
encounter a bug or are suspicious about something not working, turn it on to see exactly what it's doing.
## ๐ญ Plans
- Custom keymap support for select fields
- Select fields should preferably be selected by output text and not index