Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't update snapshots when executing a subset of tests
Co-authored-by: Mark Wubben <mark@novemberborn.net>
- Loading branch information
1 parent
78cfaa1
commit f72fab4
Showing
17 changed files
with
221 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const test = require('ava'); | ||
|
||
test('always failing snapshot', t => { | ||
t.snapshot(Date.now()); | ||
}); | ||
|
||
test.only('exclusive test', t => { // eslint-disable-line ava/no-only-test | ||
t.pass(); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Snapshot report for `contains-only.js` | ||
|
||
The actual snapshot is saved in `contains-only.js.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## always failing snapshot | ||
|
||
> Snapshot 1 | ||
1592749428423 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const test = require('ava'); | ||
|
||
test('always failing snapshot', t => { | ||
t.snapshot(Date.now()); | ||
}); | ||
|
||
test.skip('skipped test', t => { // eslint-disable-line ava/no-skip-test | ||
t.pass(); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Snapshot report for `contains-skip.js` | ||
|
||
The actual snapshot is saved in `contains-skip.js.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## always failing snapshot | ||
|
||
> Snapshot 1 | ||
1592749428431 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"ava": { | ||
"files": [ | ||
"*.js" | ||
] | ||
}, | ||
"dependencies": { | ||
"ava": "file:../../.." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Snapshot report for `test/snapshot-updates/test.js` | ||
|
||
The actual snapshot is saved in `test.js.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## cannot update snapshots when file contains exclusive tests | ||
|
||
> failed tests | ||
[] | ||
|
||
> passed tests | ||
[ | ||
{ | ||
file: 'contains-only.js', | ||
title: 'exclusive test', | ||
}, | ||
] | ||
|
||
> files where snapshots could not be updated | ||
[ | ||
{ | ||
file: 'contains-only.js', | ||
}, | ||
] | ||
|
||
## cannot update snapshots when file contains skipped tests | ||
|
||
> failed tests | ||
[ | ||
{ | ||
file: 'contains-skip.js', | ||
title: 'always failing snapshot', | ||
}, | ||
] | ||
|
||
> skipped tests | ||
[ | ||
{ | ||
file: 'contains-skip.js', | ||
title: 'skipped test', | ||
}, | ||
] | ||
|
||
> files where snapshots could not be updated | ||
[ | ||
{ | ||
file: 'contains-skip.js', | ||
}, | ||
] | ||
|
||
## cannot update snapshots when matching test titles | ||
|
||
> Snapshot 1 | ||
'Snapshots cannot be updated when matching specific tests.' | ||
|
||
## cannot update snapshots when selecting tests by line number | ||
|
||
> Snapshot 1 | ||
'Snapshots cannot be updated when selecting specific tests by their line number.' |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const test = require('@ava/test'); | ||
const exec = require('../helpers/exec'); | ||
|
||
test('cannot update snapshots when file contains skipped tests', async t => { | ||
const result = await t.throwsAsync(exec.fixture('contains-skip.js', '-u')); | ||
t.snapshot(result.stats.failed, 'failed tests'); | ||
t.snapshot(result.stats.skipped, 'skipped tests'); | ||
t.snapshot(result.stats.unsavedSnapshots, 'files where snapshots could not be updated'); | ||
}); | ||
|
||
test('cannot update snapshots when file contains exclusive tests', async t => { | ||
const result = await exec.fixture('contains-only.js', '-u'); | ||
t.snapshot(result.stats.failed, 'failed tests'); | ||
t.snapshot(result.stats.passed, 'passed tests'); | ||
t.snapshot(result.stats.unsavedSnapshots, 'files where snapshots could not be updated'); | ||
}); | ||
|
||
const stripLeadingFigures = string => string.replace(/^\W+/, ''); | ||
|
||
test('cannot update snapshots when matching test titles', async t => { | ||
const result = await t.throwsAsync(exec.fixture('contains-skip.js', '-u', '-m=snapshot')); | ||
t.snapshot(stripLeadingFigures(result.stderr.trim())); | ||
}); | ||
|
||
test('cannot update snapshots when selecting tests by line number', async t => { | ||
const result = await t.throwsAsync(exec.fixture('contains-skip.js:4', '-u')); | ||
t.snapshot(stripLeadingFigures(result.stderr.trim())); | ||
}); |