Wraps OpenFeature (CNCF vendor-neutral SDK abstraction) testing patterns: the InMemoryProvider for hermetic tests without network calls, provider registration via OpenFeature.setProvider, the getBooleanValue/getBooleanDetails evaluation API with EvaluationDetails (value, variant, reason, errorCode), hooks for evaluation side-effects, and evaluation context for targeting-rule tests. Covers TypeScript, Java, and Python SDKs, plus per-vendor hermetic-bootstrap references for Unleash (bootstrap toggles), Flagsmith (offline LocalFileHandler), and GrowthBook (initSync payload). Use when writing tests for code that resolves feature flags through the OpenFeature SDK or the Unleash / Flagsmith / GrowthBook native SDKs; LaunchDarkly has its own skill (launchdarkly-testing).
72
90%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Wraps Flagsmith server-side SDK testing patterns 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.
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
flagsmith-modes.md.
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 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")No env vars needed in offline mode:
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/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 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:
flagsmith-modes.md.