Skip to content

Snapshot testing for CLI / REPL applications, in a fun way

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

slowli/term-transcript

Repository files navigation

Capturing and Snapshot Testing for CLI / REPL Applications

Build Status License: MIT OR Apache-2.0

term-transcript is a Rust library and a CLI app that allow to:

  • Create transcripts of interacting with a terminal, capturing both the output text and ANSI-compatible color info.
  • Save these transcripts in the SVG format, so that they can be easily embedded as images into HTML / Markdown documents. Rendering logic can be customized via Handlebars template engine; thus, other output formats besides SVG (e.g., HTML) are possible.
  • Parse transcripts from SVG.
  • Test that a parsed transcript actually corresponds to the terminal output (either as text or text + colors).

The primary use case is easy to create and maintain end-to-end tests for CLI / REPL apps. Such tests can be embedded into a readme file.

Usage

term-transcript comes in two flavors: a Rust library, and a CLI app. The CLI app has slightly less functionality, but does not require Rust knowledge. See their docs and the FAQ for usage guidelines and troubleshooting advice.

Examples

An SVG snapshot of the rainbow example produced by this crate:

Snapshot of rainbow example

A snapshot of the same example with the scrolling animation and window frame:

Animated snapshot of rainbow example

A snapshot of a similar example rendered to HTML using a custom template is available as a source file and in the rendered form.

See the examples directory for more snapshot examples.

Contributing

All contributions are welcome! See the contributing guide to help you get involved.

License

All code is licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in term-transcript by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Snapshot testing for CLI / REPL applications, in a fun way

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

 
 
 

Languages