Skip to content

v8.1.0

Latest

Choose a tag to compare

@ava-launchpad ava-launchpad released this 18 Oct 19:24
Immutable release. Only release title and notes can be modified.
1202981

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

Full Changelog: v8.0.2...v8.1.0