/qa-feature-flags:launchdarkly-testingfrom qa-feature-flags
Provides LaunchDarkly TestData source for hermetic flag testing with no network calls. Covers per-test flag overrides, targeting rules, percentage rollouts, and assignment checks.
Ships in qa-feature-flags. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
LaunchDarkly's server-side SDK exposes a TestData data source
that lets tests configure flag values without any network call -
the canonical hermetic-test pattern. Per
launchdarkly.com/docs/sdk,
TestData replaces the production data source; everything else
about the SDK (variation evaluation, targeting rules, default
handling) runs the real code paths.
client.variation() / client.boolVariation().ab-test-validity-checklist.npm install --save-dev @launchdarkly/node-server-sdk
pip install launchdarkly-server-sdk
// Node.js server SDK v8+ (@launchdarkly/node-server-sdk); TestData lives in /integrations
import { init } from '@launchdarkly/node-server-sdk';
import { TestData } from '@launchdarkly/node-server-sdk/integrations';
const td = new TestData();
const client = init('sdk-test-key', {
updateProcessor: td.getFactory(),
sendEvents: false, // No event uploads in tests
});
await client.waitForInitialization();
// Configure a flag's default + per-user variation
td.update(td.flag('show-new-ui').booleanFlag().on(true));
test('flag on returns true', async () => {
td.update(td.flag('show-new-ui').booleanFlag().on(true));
const user = { key: 'user-1' };
const enabled = await client.variation('show-new-ui', user, false);
expect(enabled).toBe(true);
});
test('flag off returns default', async () => {
td.update(td.flag('show-new-ui').booleanFlag().on(false));
const enabled = await client.variation('show-new-ui', { key: 'user-1' }, false);
expect(enabled).toBe(false);
});
test('only premium users get treatment', async () => {
td.update(
td.flag('premium-feature')
.booleanFlag()
.variationForUser('premium-user-1', true)
.fallthroughVariation(false)
);
expect(await client.variation('premium-feature', { key: 'premium-user-1' }, false)).toBe(true);
expect(await client.variation('premium-feature', { key: 'free-user-1' }, false)).toBe(false);
});
test('rollout is deterministic per user', async () => {
td.update(td.flag('half-rollout').booleanFlag().on(true).variations(true, false));
// Bucketing is deterministic on user key
const r1 = await client.variation('half-rollout', { key: 'user-1' }, false);
const r2 = await client.variation('half-rollout', { key: 'user-1' }, false);
expect(r1).toBe(r2);
});
For fixture-shared tests:
import { FileDataSourceFactory } from '@launchdarkly/node-server-sdk/integrations';
const fileData = new FileDataSourceFactory({
paths: ['./tests/fixtures/ld-flags.json'],
});
const client = init('sdk-test-key', {
updateProcessor: fileData.getFactory(),
sendEvents: false,
});
The JSON file uses LaunchDarkly's flag-snapshot format. Useful for cross-language test fixtures.
afterAll(async () => {
await client.close();
});
npm test
jobs:
ld-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
- run: npm ci && npm test
No LAUNCHDARKLY_SDK_KEY needed in CI - TestData/file source
replaces it.
| Anti-pattern | Why it fails | Fix |
|---|---|---|
| Real SDK key in tests | Test traffic pollutes prod analytics | TestData / FileDataSource |
sendEvents: true in tests | Event upload from CI | sendEvents: false |
| Multiple init per test | Slow init; leaks | One global client; TestData.update per test |
Asserting exact variation result without td.update | Race vs SDK state | Always update first |
Forgetting await client.waitForInitialization() | Race; variation returns default | Always wait |
Sharing td across test files | Cross-test pollution | Per-file or per-test TestData |
No teardown client.close() | Network handles leak | Always close in afterAll |
experiment-results-interpreter.FileDataSource schema is LaunchDarkly-internal. Refer
to LD docs for the format.openfeature-sdk-testing (its flag test-matrix reference) for the matrix, then come back here to
pin each flag's value per test.openfeature-sdk-testing (OpenFeature + Unleash / Flagsmith / GrowthBook
references).feature-flag-test-harness,
ab-test-validity-checklist.evals/ci-pointed-at-the-staging-flag-environment/criteria.json (opens in a new tab)evals/ci-pointed-at-the-staging-flag-environment/task.md (opens in a new tab)evals/flag-pr-the-author-says-is-fully-covered/criteria.json (opens in a new tab)evals/flag-pr-the-author-says-is-fully-covered/task.md (opens in a new tab)evals/nightly-flag-job-green-then-hangs-until-cancelled/criteria.json (opens in a new tab)evals/nightly-flag-job-green-then-hangs-until-cancelled/task.md (opens in a new tab)evals/rollout-split-test-red-about-once-a-week/criteria.json (opens in a new tab)evals/rollout-split-test-red-about-once-a-week/task.md (opens in a new tab)evals/two-tests-went-red-when-a-third-was-deleted/criteria.json (opens in a new tab)evals/two-tests-went-red-when-a-third-was-deleted/task.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
5 skills in this plugin
/ab-test-validity-checklistUse when launching, auditing or governing an A/B test or online experiment design. Builds a per-experiment checklist and sign-off: pre-registered metric, power and guardrails, randomization unit and sample ratio mismatch checks, assignment, telemetry, peeking rules and novelty effects./experiment-results-interpreterUse for any question about reading an A/B test or experiment result, including quick ones: is it significant, should we ship variant B, why a week-one win faded. Computes significance per metric with multiple-comparison correction, reads confidence intervals, and checks novelty, interactions, Simpson's paradox, guardrails and stop-early rules before a ship decision./experiment-sdk-testingUse when code instrumented with Statsig, Optimizely, Split.io (Harness FME), Amplitude Experiment or VWO needs tests. Initializes the SDK offline from a committed config fixture, pins each test to an arm and checks assignment integrity, with per-vendor references./openfeature-sdk-testingUse whenever code that reads feature flags through OpenFeature, Unleash, Flagsmith or GrowthBook needs tests: InMemoryProvider for hermetic tests, evaluation details, hooks and targeting context in TypeScript, Java and Python, plus a flag test-matrix workflow. LaunchDarkly has launchdarkly-testing.npx claudepluginhub testland/qa --plugin qa-feature-flagsOther plugins' skills for the same job