v8.1.0
Added 3
- Add an overload for t.snapshot() that accepts an options object with formatAsCodeBlock when the expected value is a string
- Store string snapshots verbatim and render them as fenced code blocks in .snap.md files when formatAsCodeBlock is set
- Support formatAsCodeBlock set to true for a generic code block or to a non-empty language identifier string for syntax highlighting
Changed 1
- Improve startup and test-run performance, with about 40% faster runs for many small test files, about 30% faster runs for a single file with thousands of tests, and about 50% faster runs for many files executed concurrently
From AVA
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 https://github.com/avajs/ava/pull/3460
- Support code block formatting for string snapshots by @novemberborn in https://github.com/avajs/ava/pull/3449
Full Changelog: https://github.com/avajs/ava/compare/v8.0.2...v8.1.0