(I'm still just reading/working on the code and testing edge cases. This one could affect someone in actual usage, though.)
What happened
Normally, snapshots only increment nextSnapshotIndex if they don't have an id. Skipped snapshots, however, always increment nextSnapshotIndex. If a snapshot with an id is skipped, it effectively pushes down any subsequent snapshot assertions, causing them to compare against the expected value of the next snapshot in order. If there was a next snapshot, it will probably fail; if not, it will record a new snapshot that doesn't actually exist.
What you expected to happen
Skipping an assertion should have no effect on the behavior of other assertions.
Sample code
const test = require('ava');
test('some snapshots', t => {
t.snapshot(null, {id: 'an id'}); // <--
t.snapshot('one');
t.snapshot('two');
});
Run once, then change the first line of the test to t.snapshot.skip(null, {id: 'an id'}); and run again. The second assertion will fail and the third will record a "Snapshot 3".
What you're trying to do
Skip a snapshot assertion that has an id.
(I'm still just reading/working on the code and testing edge cases. This one could affect someone in actual usage, though.)
What happened
Normally, snapshots only increment
nextSnapshotIndex
if they don't have anid
. Skipped snapshots, however, always incrementnextSnapshotIndex
. If a snapshot with anid
is skipped, it effectively pushes down any subsequent snapshot assertions, causing them to compare against the expected value of the next snapshot in order. If there was a next snapshot, it will probably fail; if not, it will record a new snapshot that doesn't actually exist.What you expected to happen
Skipping an assertion should have no effect on the behavior of other assertions.
Sample code
Run once, then change the first line of the test to
t.snapshot.skip(null, {id: 'an id'});
and run again. The second assertion will fail and the third will record a "Snapshot 3".MRE
Configuration
npx ava
.