Does "VerifyTests / Verify" have global settings?

604 views Asked by At

@Simon (https://stackoverflow.com/users/53158/simon)

In the docs it is mentioned how to setup a custom output directory for Verify and it works fine, but it is pain to do it for every test.

await Verify("value")
    .UseDirectory("CustomDirectory");

ApprovalTests have a global UseApprovalSubdirectory which solves this issue. So I wonder is there anything similar in VerifyTests / Verify?
The reason is that VS2022 does not allow renaming nested files, so I need to go to the file explorer and rename files there (pain...)

Related GitHub issue: https://github.com/VerifyTests/Verify/issues/482

1

There are 1 answers

0
Simon On BEST ANSWER

you should be able to use DerivePathInfo to achieve this. So in your case

VerifierSettings.DerivePathInfo(
    (sourceFile, projectDirectory, type, method) =>
    {
        return new(
            directory: Path.Combine(projectDirectory, "CustomDirectory"),
            typeName: type.Name,
            methodName: method.Name);
    });