During the ongoing development of graphql-perl, I have found it valuable to generate data structures, and to compare those with expected values. Often, these have been highly detailed rather than a subset, because I wanted to know when anything changed.

When, however, something does validly have to change, it might change quite a few "expected" outputs. If those all need updating manually, that is a lot of repetitive activity. What if the computer could do that instead? What if Perl had "snapshot testing" as used in JavaScript frontend development, most popularly in Jest?

use Test::Snapshot; my $got = function_generating_data(); is_deeply_snapshot $got, 'test description'; # could also be in a subtest

Test::Snapshot automates this! Imagine you have t/subdir/filename.t , a subtest called "my subtest", and a test you've described as "test description". is_deeply_snapshot looks for its "expected" data in a file called t/subdir/snapshots/filename_t/my_subtest/test_description . That data will be read in, and eval -ed. I considered making a separate is_snapshot for simple text, but found that Data::Dumper with the right settings made text so readable that I felt it unnecessary. The data comparison is done using Test::More::is_deeply .