ava icon indicating copy to clipboard operation
ava copied to clipboard

Allow further customization of where snapshots are stored

Open novemberborn opened this issue 4 years ago • 2 comments

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.

novemberborn avatar Dec 31 '21 15:12 novemberborn

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

Riskier but more powerful.

Airkro avatar Mar 03 '23 05:03 Airkro

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.

novemberborn avatar Mar 06 '23 15:03 novemberborn