Closed nyurik closed 2 months ago
Yes, is this the same as https://github.com/mitsuhiko/insta/issues/377; do we need more flexibility or is the proposed default there of no repetition sufficient?
Closing as likely dupe but please reopen if mistaken, thank you
In some cases, especially when the snapshot files reside in a sub-directory next to the test files, snapshot filenames become increasingly hard to manage. I would like to propose a setting to remove some beginning parts of the module name with a setting.
Example setup
My project crate
myproj
contains a proc macro in the cratemyproj-macros
. When testing proc-macros, it is the easiest to keep the tests in a sub-directory, e.g../myproj-macros/src/tests
instead of being in parallel to./myproj-macros/src
because procmacro crates cannot have any public exported functions (this way these are unit, not integration tests, and the entire test submodule is behind#[cfg(test)]
).If my tests use
insta
, the snapshot dir is created next to them in the./myproj-macros/src/tests/snapshots
. The filename then becomes huge (assuming i am using named tests)A more readable name would be
testfilename__testname.snap
Suggestion
The test name is generated with
module_path!()
-- which in my case ismyproj_macros::tests::testfilename
. I think it would be great if we could remove some prefix from it. Some approaches:myproj_macros::tests
-- that string must exits in the module name and end in::
(fail otherwise)