Code block formatting for string snapshots
This release adds an overload for t.snapshot():
t.snapshot(expected, {formatAsCodeBlock}, message?)
The overload is only accepted when expected is a string. The string is stored verbatim and rendered as a fenced code block in the resulting .snap.md file. Set formatAsCodeBlock to true for a generic code block, or a non-empty language identifier string for syntax highlighting:
test('generates code', t => {
const code = generate();
t.snapshot(code, {formatAsCodeBlock: 'js'});
});The resulting snapshots can only be read with AVA 8.1 or newer, but snapshots that do not contain code blocks are backwards compatible. And existing snapshots can still be read, of course.
Performance improvements
- ~40% faster for many small test files (startup-bound)
- ~30% faster for a single file with thousands of tests
- ~50% faster for many files run concurrently
What's Changed
- Improve startup and test-run performance by @sindresorhus in #3460
- Support code block formatting for string snapshots by @novemberborn in #3449
Full Changelog: v8.0.2...v8.1.0