Skip to content

How does AVA decide where to put snapshots #2765

Answered by novemberborn
electerious asked this question in Q&A
Discussion options

You must be logged in to vote

See:

ava/lib/snapshot-manager.js

Lines 396 to 405 in c57067b

const parts = new Set(path.relative(projectDir, testDir).split(path.sep));
if (parts.has('__tests__')) {
return path.join(testDir, '__snapshots__');
}
if (parts.has('test') || parts.has('tests')) { // Accept tests, even though it's not in the default test patterns
return path.join(testDir, 'snapshots');
}
return testDir;

__snapshots__ if the relative path to the test file contains a __tests__ directory, snapshots if it contains test or tests directories, and otherwise directly alongside the test file.

You can also configure snapshotDir, in which all snapshots are the…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@lukasholzer
Comment options

@novemberborn
Comment options

@lukasholzer
Comment options

@novemberborn
Comment options

@novemberborn
Comment options

Answer selected by electerious
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants