Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow further customization of where snapshots are stored #2921

Open
novemberborn opened this issue Dec 31, 2021 · 2 comments
Open

Allow further customization of where snapshots are stored #2921

novemberborn opened this issue Dec 31, 2021 · 2 comments

Comments

@novemberborn
Copy link
Member

Per discussion, in an ava.config.js:

export default {
  snapshotDir (testFile) {
    return new URL('.', testFile)
  }
}

Up till now snapshotDir is a fixed directory under which snapshot files are stored, with subdirectories that match the relative location of the corresponding test files. My suggestion is we make it a function which receives a file URL string (like import.meta.url) and returns a file URL instance that points at the directory within which the snapshots should be stored. The above example would store them alongside the test files.

The main process will have to run this function before it spins up the test worker thread and pass the resulting directory to the runner.

@Airkro
Copy link

Airkro commented Mar 3, 2023

How about something like this:
https://node-tap.org/docs/api/snapshot-testing/#even-more-advanced-customization-warning-footguns-ahead

Riskier but more powerful.

@novemberborn
Copy link
Member Author

How about something like this: https://node-tap.org/docs/api/snapshot-testing/#even-more-advanced-customization-warning-footguns-ahead

Riskier but more powerful.

AVA is set up to have one snapshot file per test file. I don't think it's worthwhile to change that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants