A command-line tool that uses the Verify library for regular files (without requiring you to create a unit test project).
Install as .NET global tool
dotnet tool install -g Verify.Cli
Once installed, invoke directly via the verify
command.
An image is published to Docker Hub. Ensure that you create a volume mapping (via the -v
parameter) so that the container can access the files you wish to verify.
Bash:
docker run --rm -v $PWD:/tmp flcdrg/verify-cli --file /tmp/examples/same.json
PowerShell:
docker run --rm -v ${pwd}:/tmp verify-cli:latest --file /tmp/examples/same.json
If you run this tool interactively, then you'll get a similar experience that you would using VerifyTests in a .NET unit test project. Verify.Cli will utilise any existing compatible file diff tool to display the diff.
verify --file <path to file to verify> [--verified-dir <directory>]
The first time you use Verify.Cli, it will output the contents of the file.
--file
or-f
: The file to verify (required)--verified-dir
or-d
: Directory to store/look for .verified files (optional)--scrub-inline-datetime
: Format for inline date times to scrub, e.g., 'yyyy-MM-ddTHH:mm:ss.fffZ' (optional)--scrub-inline-pattern
: Regex pattern to match inline strings for scrubbing, e.g., '"/astro/[^"]+"|(?<prefix>")/_astro/[^"]+(?<suffix>")' (optional)--scrub-inline-remove
: Text to match and remove from the file content, e.g., 'temp-id-123' (optional)--verbosity
: Set the verbosity level. Options are: quiet, minimal, normal, detailed, diagnostic (optional, default: normal)
Basic usage:
verify --file C:\tmp\example.txt
With custom verified files directory:
verify --file C:\tmp\example.txt --verified-dir C:\MyVerifiedFiles
This will look for the verified file at C:\MyVerifiedFiles\example.txt.verified.txt
instead of the default location next to the source file.
With date time scrubbing:
verify --file C:\tmp\log.txt --scrub-inline-datetime "yyyy-MM-ddTHH:mm:ss.fffZ"
This will scrub inline date times matching the specified format from the file content before verification.
With pattern scrubbing:
verify --file C:\tmp\output.html --scrub-inline-pattern "\"/astro/[^\"]+\""
This will scrub inline strings matching the regex pattern (e.g., dynamic asset paths like "/astro/chunk-123.js") from the file content before verification.
With pattern scrubbing using named groups to preserve parts:
verify --file C:\tmp\output.html --scrub-inline-pattern "(?<prefix>\")/_astro/[^\"]+(?<suffix>\")"
This will replace the dynamic part while preserving the prefix and suffix (e.g., "/_astro/chunk-123.js" becomes the preserved prefix and suffix).
With text removal:
verify --file C:\tmp\output.html --scrub-inline-remove "data-temp-id"
This will remove all instances of the text "data-temp-id" from the file content before verification.
With verbosity control:
verify --file C:\tmp\example.txt --verbosity quiet
This will run with minimal output (quiet mode). Available verbosity levels are:
quiet
: Minimal output, only errors and critical informationminimal
: Basic output with essential informationnormal
: Standard output (default)detailed
: More detailed output including additional informationdiagnostic
: Full diagnostic output for troubleshooting
You can combine options:
verify --file C:\tmp\log.txt --verified-dir C:\MyVerifiedFiles --scrub-inline-datetime "yyyy-MM-dd HH:mm:ss" --scrub-inline-pattern "id=\"[^\"]+\"" --scrub-inline-remove "temp-session" --verbosity detailed
When the files match, the tool exits with code 0 and produces no output.
Unhandled exception: VerifyException: Directory: C:\tmp
New:
- Received: example.txt.received.txt
Verified: example.txt.verified.txt
FileContent:
New:
Received: example.txt.received.txt
This is
a text file.
Your diff tool of choice (if found by the Verify's DiffEngine library) can then be used to compare to the verified file (if it exists), or create it (if the first time).
If the verified file matches the received file, then there is no output (and the exit code is zero).
If the received file is different from the verified file, then a diff will be shown in the console, a non-zero exit code will be returned, and if in an interactive environment with a supported diff tool, then that tool will be launched.
Unhandled exception: VerifyException: Directory: C:\tmp
NotEqual:
- Received: example.txt.received.txt
Verified: example.txt.verified.txt
FileContent:
NotEqual:
Received: example.txt.received.txt
This is
an updated text file.
Verified: example.txt.verified.txt
This is
a text file.
Example with Beyond Compare launched: