Is the feature request related to a problem
ProjectRelative snapshots folder quickly becomes unwieldy.
Describe the solution
I think it would be easier to reason about what snapshots are orphaned if files inside the ProjectRelativeDirectory would be nested in folders that mirrored the path of the source.
example:
Root
├── Tests
│ └── Foo
│ └── FooTests.cs
└── Snapshots
└── Foo
└── FooTests.Bar.verified.json
Additional context
This accomplishes the above. But would be nice with built-in support 😄
/// <summary>
/// Configures Verify to store snapshots under a root directory while mirroring
/// the relative folder structure of the test source files.
/// </summary>
/// <param name="snapshotsDirectoryName">
/// The project-relative root directory where snapshots are written.
/// </param>
/// <param name="testsDirectoryName">
/// The project-relative root directory used to calculate each test file's relative path.
/// </param>
private static void UseMirroredSnapshotDirectories(
string snapshotsDirectoryName,
string testsDirectoryName
) =>
Verifier.DerivePathInfo(
(sourceFile, projectDirectory, type, method) =>
{
var testsDirectory = Path.Combine(projectDirectory, testsDirectoryName);
var sourceDirectory = Path.GetDirectoryName(sourceFile)!;
var relativeDirectory = Path.GetRelativePath(testsDirectory, sourceDirectory);
var snapshotDirectory =
relativeDirectory.StartsWith("..", StringComparison.Ordinal)
? Path.Combine(projectDirectory, snapshotsDirectoryName)
: relativeDirectory == "."
? Path.Combine(projectDirectory, snapshotsDirectoryName)
: Path.Combine(projectDirectory, snapshotsDirectoryName, relativeDirectory);
return new(
directory: snapshotDirectory,
typeName: type.Name,
methodName: method.Name
);
}
);
Is the feature request related to a problem
ProjectRelative snapshots folder quickly becomes unwieldy.
Describe the solution
I think it would be easier to reason about what snapshots are orphaned if files inside the ProjectRelativeDirectory would be nested in folders that mirrored the path of the source.
example:
Additional context
This accomplishes the above. But would be nice with built-in support 😄