To solve this issue, we have two options. Either we start implementing a fixed failure threshold as part of the jest-image-snapshot configuration. This option might solve the issue right now, but as more or less text is added to the project, this failure threshold should be updated.
This option might also create the foundation for more problems, since unintended failure might be hiding within the failure threshold (often starts happening around 1% failure threshold).
The other, and possibly more attractive, option, is to render the application on the same OS as the latest committed images are rendered.
This means that the committed images should be available for the pipeline in a Linux rendered version, while they should also be available in a Windows rendered version for the developer environment. In my specific scenario, I achieved this by only committing the Linux rendered images from the pipeline agent to the project. Windows rendered images were handled locally on the developer environment and was integrated as part of the workflow.
OS dependent images requires a smart pipeline setup. I therefore created a new build job, separate from the regular test job. Let’s call it the “snapshot job”.
The snapshot job was set only to run when manually triggered. Eventually, when it would be triggered, it would then run all snapshot tests and commit the images. This commit would then in turn trigger the regular test job on the pipeline, which should go through all tests without any problems.
This is at least the basic concept. However, things get a bit tricky when we combine this strategy with a branching strategy.
In the following section, I am going to outline how I achieved the described commit-flow. The section is followed by a visualization of the developers workflow, when committing new visual changes and how the workflow is integrated into the overall branching strategy.