Wraps Flagsmith server-side SDK testing patterns (feature flags / feature toggles) so tests run without calling the Flagsmith API: offline mode with LocalFileHandler + a downloaded environment.json snapshot, local-evaluation mode (no per-request network), and default_flag_handler for per-feature mocked fallbacks, via the get_environment_flags / get_identity_flags evaluation paths. Use when writing feature-flag tests for code that uses Flagsmith, mocking flag values, or testing feature toggles offline in CI.
75
94%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
High
Do not use without reviewing
This plugin was archived by the owner on Oct 11, 2026
Reason: Tile archived: Retired from testland/qa (merged into another skill or removed).
Flagsmith (open-source, also SaaS at flagsmith.com) supports three test-friendly modes per docs.flagsmith.com/clients/server-side:
environment.json snapshot; zero network.Offline mode is the default choice for tests; local-evaluation
and default_flag_handler detail live in
references/flagsmith-modes.md.
default_flag_handler.pip install flagsmith (Python) or npm install --save-dev flagsmith-nodejs (Node).LocalFileHandler pointed at that fixture, so tests make zero network calls.default_flag_handler returning a DefaultFlag with the value under test (see references/flagsmith-modes.md).get_environment_flags() for environment-scoped flags, or get_identity_flags(identifier, traits=...) for per-user flags.is_feature_enabled(...) and get_feature_value(...), and add an integrity test that the same identity resolves consistently.offline_mode=True and no environment_key set, get_environment_flags() must return the fixture's flags with zero network calls (run the suite with the machine offline or under a network-blocking fixture to confirm). If it raises or attempts an API call, the LocalFileHandler environment_document_path is wrong or offline_mode is unset - fix the path and re-run.pytest tests/flagsmith/ into CI - offline mode needs no env vars.Per docs.flagsmith.com:
from flagsmith import Flagsmith
from flagsmith.offline_handlers import LocalFileHandler
local_file_handler = LocalFileHandler(environment_document_path="tests/fixtures/flagsmith-environment.json")
flagsmith = Flagsmith(offline_mode=True, offline_handler=local_file_handler)Download the environment.json via the Flagsmith CLI, then commit it (refresh deliberately):
flagsmith environment-document --api-key=<server-key> --output=tests/fixtures/flagsmith-environment.jsondef test_environment_flag():
flags = flagsmith.get_environment_flags()
assert flags.is_feature_enabled("secret_button") is False
assert flags.get_feature_value("secret_button") == '{"colour": "#b8b8b8"}'
def test_identity_flag():
flags = flagsmith.get_identity_flags(
identifier="user@example.com",
traits={"plan": "premium"},
)
assert flags.is_feature_enabled("premium_feature") is TrueIntegrity test - the same identity must resolve consistently:
def test_same_identity_consistent():
f1 = flagsmith.get_identity_flags("u1")
f2 = flagsmith.get_identity_flags("u1")
assert f1.is_feature_enabled("flag-x") == f2.is_feature_enabled("flag-x")jobs:
flagsmith-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
- run: pip install flagsmith
- run: pytest tests/flagsmith/No env vars needed in offline mode.
A service reads a secret_button flag (boolean plus a JSON colour value) and a premium_feature flag gated on a plan trait, tested fully offline:
LocalFileHandler (offline-mode snippet above).secret_button is not in the snapshot yet, so register a default_flag_handler for it (see references/flagsmith-modes.md).get_environment_flags() and get_identity_flags(...) (evaluate snippet above).Result: pytest tests/flagsmith/ runs green in CI with zero network access and no analytics pollution.
default_flag_handler, anti-patterns, and limitations:
references/flagsmith-modes.md.feature-flag-test-matrix-reference.launchdarkly-testing,
unleash-testing,
growthbook-testing.