How to run snapshot tests on docfx forked repository #9743
Replies: 3 comments 1 reply
-
OS/hardware setup may affect screenshot test output, so it is excluded from locally. We can perhaps replace the current approach with a visual regression test service such as percy which is free to open source projects. Other suggestions on visual regression services are also welcome. |
Beta Was this translation helpful? Give feedback.
-
We are now using Percy for visual testing and snapshot tests can run locally now. |
Beta Was this translation helpful? Give feedback.
-
Thanks for updates. I'm trying to run percy tests with following steps. Steps to execute percy tests at local environment
git switch main
$env:PERCY_TOKEN = '[Write-only Token]'
dotnet build -c Release
percy exec -- dotnet test -c Release -f net8.0 --no-build --filter Stage=Percy
git switch [my-feature-branch]
$env:PERCY_TOKEN = '[Write-only Token]'
$env:PERCY_TARGET_BRANCH = 'main'
dotnet build -c Release
percy exec -- dotnet test -c Release -f net8.0 --no-build --filter Stage=Percy |
Beta Was this translation helpful? Give feedback.
-
When running snapshot tests on local environment with docfx forked repository.
A lot of diffs occurs.
It can be reduced by following steps.
1. Enable snapshot tests
By default. SnapShot tests is skipped for non-CI environment.
It need to set environment variable to run these tests.
1.1. Edit
test\docfx.Snapshot.Tests\ModuleInitializer.cs
1.2. Add following line.> Environment.SetEnvironmentVariable("SNAPSHOT_TEST", "EnableSnapshotTest");
2. Modify
src\Docfx.Common\Git\GitUtility.cs
fileModify following functions to replace repository dependent string.
TryGetFileDetail
RawContentUrlToContentUrl
GetSourceUrl
(e.g. `url.Replace("filzrev", "dotnet").Replace(".git", "");
Beta Was this translation helpful? Give feedback.
All reactions