Skip to content

Commit 2bf983f

Browse files
committed
Test that t.snapshot.skip() prevents updating snapshots
1 parent 9f2be0d commit 2bf983f

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const test = require('ava');
2+
3+
test('always failing snapshot', t => {
4+
t.snapshot(Date.now());
5+
});
6+
7+
test('skipped assertion', t => {
8+
t.snapshot.skip(Date.now()); // eslint-disable-line ava/no-skip-assert
9+
t.pass();
10+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Snapshot report for `contains-skip-assertion.js`
2+
3+
The actual snapshot is saved in `contains-skip-assertion.js.snap`.
4+
5+
Generated by [AVA](https://avajs.dev).
6+
7+
## always failing snapshot
8+
9+
> Snapshot 1
10+
11+
1607992742963
Binary file not shown.

test/snapshot-updates/snapshots/test.js.md

+28
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,31 @@ Generated by [AVA](https://avajs.dev).
6666
> Snapshot 1
6767
6868
'Snapshots cannot be updated when selecting specific tests by their line number.'
69+
70+
## cannot update snapshots when skipping snapshot assertions
71+
72+
> failed tests
73+
74+
[
75+
{
76+
file: 'contains-skip-assertion.js',
77+
title: 'skipped assertion',
78+
},
79+
]
80+
81+
> passed tests
82+
83+
[
84+
{
85+
file: 'contains-skip-assertion.js',
86+
title: 'always failing snapshot',
87+
},
88+
]
89+
90+
> files where snapshots could not be updated
91+
92+
[
93+
{
94+
file: 'contains-skip-assertion.js',
95+
},
96+
]
71 Bytes
Binary file not shown.

test/snapshot-updates/test.js

+7
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,10 @@ test('cannot update snapshots when selecting tests by line number', async t => {
2424
const result = await t.throwsAsync(exec.fixture(['contains-skip.js:4', '-u']));
2525
t.snapshot(exec.cleanOutput(result.stderr));
2626
});
27+
28+
test('cannot update snapshots when skipping snapshot assertions', async t => {
29+
const result = await t.throwsAsync(exec.fixture(['contains-skip-assertion.js', '-u']));
30+
t.snapshot(result.stats.failed, 'failed tests');
31+
t.snapshot(result.stats.passed, 'passed tests');
32+
t.snapshot(result.stats.unsavedSnapshots, 'files where snapshots could not be updated');
33+
});

0 commit comments

Comments
 (0)