launchdarkly-testing
/launchdarkly-testing
Wraps LaunchDarkly server-side SDK testing patterns: TestData data source for hermetic tests (no network), file-based data source for fixture-driven tests, flag override patterns (TestData.update for per-test flag values), and assignment-integrity tests. Use when writing tests for code that uses LaunchDarkly flags; to decide which flag combinations those tests should cover in the first place, see feature-flag-test-matrix-reference.
- Author
- testland ↗
- Repository
- qa ↗
- Licence
- MIT
- Last repository change
- 20.10.2026
Assessment and security
- Files in this package
- 12
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 4
No signals detected. Repository changed on 20.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Wraps LaunchDarkly server-side SDK testing patterns: TestData data source for hermetic tests (no network), file-based data source for fixture-driven tests, flag override patterns (TestData.update for per-test flag values), and assignment-integrity tests. Use when writing tests for code that uses LaunchDarkly flags; to decide which flag combinations those tests should cover in the first place, see feature-flag-test-matrix-reference.
Original author description
Wraps LaunchDarkly server-side SDK testing patterns: TestData data source for hermetic tests (no network), file-based data source for fixture-driven tests, flag override patterns (TestData.update for per-test flag values), and assignment-integrity tests. Use when writing tests for code that uses LaunchDarkly flags; to decide which flag combinations those tests should cover in the first place, see feature-flag-test-matrix-reference.
How it works
- Overview
- When to use
- Authoring
- Running
- CI integration
- Anti-patterns
- Limitations
- References
SKILL.md preview
---
name: launchdarkly-testing
description: "Wraps LaunchDarkly server-side SDK testing patterns: TestData data source for hermetic tests (no network), file-based data source for fixture-driven tests, flag override patterns (TestData.update for per-test flag values), and assignment-integrity tests. Use when writing tests for code that uses LaunchDarkly flags; to decide which flag combinations those tests should cover in the first place, see feature-flag-test-matrix-reference."
---
# launchdarkly-testing
## Overview
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](https://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.
## When to use
- Unit / integration tests for code that calls
`client.variation()` / `client.boolVariation()`.
- Tests asserting on targeting-rule behaviour (segment matching,
percentage rollout).
- Assignment-integrity tests per `ab-test-validity-checklist`.
## Authoring
### Install
```bash
npm install --save-dev launchdarkly-node-server-sdk
pip install launchdarkly-server-sdk
```
### Initialize with TestData
```typescript
import * as LaunchDarkly from 'launchdarkly-node-server-sdk';
const td = LaunchDarkly.TestData.dataSource();
const client = LaunchDarkly.init('sdk-test-key', {
updateProcessor: td,
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));
```
### Variation evaluation
```typescript
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);
});
```
### Targeting rules
```typescript
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);
});
```
### Percentage rollout (deterministic assignment)
```typescript
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);
});
```
### File-based data source (alternative)
For fixture-shared tests:
```typescript
const fileSource = LaunchDarkly.FileDataSource({
paths: ['./tests/fixtures/ld-flags.json'],
});
const client = LaunchDarkly.init('sdk-test-key', {
updateProcessor: fileSource,
sendEvents: false,
});
```
The JSON file uses LaunchDarkly's flag-snapshot format. Useful
for cross-language test fixtures.
### Teardown
```typescript
afterAll(async () => {
await client.close();
});
```
## Running
```bash
npm test
```
## CI integration
```yaml
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-patterns
| 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 |
## Limitations
- **TestData is server-side-SDK-specific.** Client-side SDKs
have their own offline modes.
- **Doesn't validate LaunchDarkly's UI-side rollout math.**
Platform-side bucketing is separately tested.
- **No experiment-results validation.** That's
`feature-flag-experiment-validator` (in the qa-shift-right plugin).
- **`FileDataSource` schema is LaunchDarkly-internal.** Refer
to LD docs for the format.
## References
- LaunchDarkly SDK docs:
[launchdarkly.com/docs/sdk](https://launchdarkly.com/docs/sdk).
- TestData data source guide:
[launchdarkly.com/docs/sdk/features/test-data-sources](https://launchdarkly.com/docs/sdk/features/test-data-sources).
- File-based data source:
[launchdarkly.com/docs/sdk/features/flags-from-files](https://launchdarkly.com/docs/sdk/features/flags-from-files).
- Deciding WHICH flag combinations to cover is a separate step this skill does
not do: when code branches on several flags, load
`feature-flag-test-matrix-reference` for the matrix, then come back here to
pin each flag's value per test.
- Sibling SDK umbrella:
`openfeature-sdk-testing` (OpenFeature + Unleash / Flagsmith / GrowthBook
references).
- Cross-plugin:
`feature-flag-test-harness`,
`ab-test-validity-checklist`.
Files in this package (12)
- SKILL.md 6 KB
- .tessl-plugin/plugin.json 1 KB
- evals/ci-pointed-at-the-staging-flag-environment/criteria.json 6 KB
- evals/ci-pointed-at-the-staging-flag-environment/task.md 17 KB
- evals/flag-pr-the-author-says-is-fully-covered/criteria.json 6 KB
- evals/flag-pr-the-author-says-is-fully-covered/task.md 14 KB
- evals/nightly-flag-job-green-then-hangs-until-cancelled/criteria.json 6 KB
- evals/nightly-flag-job-green-then-hangs-until-cancelled/task.md 16 KB
- evals/rollout-split-test-red-about-once-a-week/criteria.json 5 KB
- evals/rollout-split-test-red-about-once-a-week/task.md 13 KB
- evals/two-tests-went-red-when-a-third-was-deleted/criteria.json 5 KB
- evals/two-tests-went-red-when-a-third-was-deleted/task.md 13 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · testland/qa | 100 | MIT |
| testland/qa-skills | 100 | MIT |
Database snapshot: 13.11.2026 · package version 4a99be8e27b3 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100launchdarkly
Server-side and client-side LaunchDarkly flag evaluation (project key `agent-native`). Use when reading a LaunchDarkly flag from an action, plugin, or component, or when wiring `LAUNCHDARKLY_SDK_KEY`. Distinct from the framework's own `feature-flags` system. - 100launchdarkly-flag-create
Create and configure LaunchDarkly feature flags in a way that fits the existing codebase. Use when the user wants to create a new flag, wrap code in a flag, add a feature toggle, or set up an experiment. Guides exploration of existing patterns before creating. - 100launchdarkly-flag-create
Create and configure LaunchDarkly feature flags in a way that fits the existing codebase. Use when the user wants to create a new flag, wrap code in a flag, add a feature toggle, or set up an experiment. Guides exploration of existing patterns before creating. - 90launchdarkly-flag-command
Resolve `/flag` style requests into the right LaunchDarkly flag lookup flow. Use when the user types `/flag`, asks to quickly find a flag by name/key, wants a direct flag detail summary, or needs fast disambiguation between similar flags. - 90launchdarkly-flag-discovery
Audit your LaunchDarkly feature flags to understand the landscape, find stale or launched flags, and assess removal readiness. Use when the user asks about flag debt, stale flags, cleanup candidates, flag health, or wants to understand their flag inventory. - 100openfeature-sdk-testing
Use 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.