question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make snapshot file path configurable

See original GitHub issue

Hey, it’s me again.

The current snapshots are saved in the relative path of the test spec file, under __snapshots__ folder. To improve the performance, we introduce an index_spec.js to collect all test files in the same folder and run them together, now we have 2 issues:

  1. If run with index_spec.js, all snapshots are saved in one index_spec.js.snap, which is not easy to track when we have many cases.
  2. If we just run one spec file, say a_spec.file, the snapshot is generated again a_spec.js.snap in diff path, which will be AUTOPASS because it’s not existed before.

I have an idea: generate the file name according to the key word in the test title, but it seems annoying since we need to unify all test titles and index_spec.js is not in common use. So I would like to hear from you, you should have better vision.

Here is my proposal code change(the test title should follow the pattern - [Filename] XXXXXX): function getSnapshotFilename(testFile, snapshotTitle) { const dir = path.join(path.dirname(testFile), DIR_SNAPSHOTS); const filename = `${snapshotTitle.match(/\[(.+)?\]/)[1]}.snap`; return path.join(dir, filename); }

Here is the context of index_spec.js: const reqCont = require.context('./', true, /_spec\.js?$/); reqCont.keys().forEach(filename => reqCont(filename));

And here is our case file structure screenshot: image

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
librehatcommented, Mar 13, 2020

It’ll be great if we can make the path configurable so we put the image snapshots in a completely different directory

1reaction
ALeschinskycommented, Nov 21, 2019

Hello, any updates on this issue? I’m trying to use cypress-plugin-snapshots in an Angular app and it works fine, but the actual screenshots are saved under dist/ folder where the tests are compiled from typescript into javascript. This folder is excluded from git (in .gitignore), so the snapshots are not really part of the repository this way… How can we move the screenshots to where the tests are, so that they are pushed to git and version tracked?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to configure jest snapshot locations - Stack Overflow
Solution. Create a file: I used - 'jest/snapshotResolver.js' module.exports = { resolveSnapshotPath ...
Read more >
Creating snapshots in a different location than default virtual ...
In ESX/ESXi 3.x and 4.x, all files comprising snapshots are created in the virtual machine's working directory. By default, the working ...
Read more >
Configure the Snapshot Path for Backup Node
Configure the Snapshot Path for Backup Node · Log into the Backup Server as a root user. · Navigate to the node folder:...
Read more >
Taking configuration snapshots - Forcepoint
The Change Snapshot Directory field displays the name of the directory where Content Gateway saves configuration snapshots. The default location is the ...
Read more >
Snapshot configuration - IBM
Make sure that parameters such as file and path names are different for each instance to ensure that the snapshot files from the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found