Table of Contents

Class SnapshotAcceptMode

Namespace
SnapshotAssertions
Assembly
SnapshotAssertions.dll

Detection of accept-mode based on the SNAPSHOT_ACCEPT and CI environment variables. Pure, no IO; the caller is responsible for actually overwriting the baseline when accept-mode is active.

public static class SnapshotAcceptMode
Inheritance
SnapshotAcceptMode
Inherited Members

Remarks

Accept-mode is enabled when SNAPSHOT_ACCEPT is set to a truthy value (one of 1, true, or yes; case-insensitive). It is unconditionally disabled in CI: if the CI environment variable is set to a truthy value (which all major hosted CI services do: GitHub Actions, GitLab CI, Azure Pipelines, CircleCI, etc.), accept-mode is refused even if SNAPSHOT_ACCEPT is set, to prevent a stray pipeline configuration from silently accepting baseline drift.

The CI guard reads CI rather than the runner-specific variables (GITHUB_ACTIONS, GITLAB_CI, TF_BUILD, etc.) because CI is the cross-runner canonical signal: every major runner sets it. This keeps the rule one-line and runner-agnostic.

Fields

AcceptVariableName

The environment variable consulted to enable accept-mode.

public const string AcceptVariableName = "SNAPSHOT_ACCEPT"

Field Value

string

CiVariableName

The environment variable consulted to detect a CI environment.

public const string CiVariableName = "CI"

Field Value

string

Methods

IsActive()

Returns true when accept-mode is enabled and the process is not in CI.

public static bool IsActive()

Returns

bool

true if the actual content should be written over the expected baseline on mismatch.

IsActive(string?, string?)

Pure overload for testability: classify the supplied raw values without touching the process environment.

public static bool IsActive(string? snapshotAcceptValue, string? ciValue)

Parameters

snapshotAcceptValue string

The raw value of the SNAPSHOT_ACCEPT environment variable, or null if unset.

ciValue string

The raw value of the CI environment variable, or null if unset.

Returns

bool

true if accept-mode is enabled AND the process is not in CI.

IsTruthy(string?)

Whether value is one of the recognised truthy strings (1, true, yes; case-insensitive). null and empty strings are falsy.

public static bool IsTruthy(string? value)

Parameters

value string

The value to classify.

Returns

bool

true if truthy.