Skip to content

chore: init @launchdarkly/client-testing-plugin#1373

Merged
joker23 merged 3 commits into
mainfrom
skz/sdk-1997/client-test-data-plugin
Jun 2, 2026
Merged

chore: init @launchdarkly/client-testing-plugin#1373
joker23 merged 3 commits into
mainfrom
skz/sdk-1997/client-test-data-plugin

Conversation

@joker23
Copy link
Copy Markdown
Contributor

@joker23 joker23 commented May 8, 2026

This PR pushes the initial implementation of the client test data plugin

SDK-2124


Note

Low Risk
New dev-only tooling with no production SDK behavior changes; risk is limited to monorepo build/test wiring for the new package.

Overview
Introduces @launchdarkly/client-testing-plugin, a new workspace package that exposes TestData as an SDK plugin for tests and local dev. It drives the existing registerDebug / LDDebugOverride path so flag values can be seeded, updated (with change: events), removed, or cleared without network I/O.

The package ships with README usage docs, tsup build output (ESM/CJS + types), Jest setup (jsdom stubs for EventSource and crypto.subtle), unit tests against a mock debug override, and browser SDK integration tests. The monorepo wires the package into root package.json workspaces and tsconfig.json references; .gitignore swaps .claude/stacks for .claude/tmp.

Reviewed by Cursor Bugbot for commit c2fa0f6. Bugbot is set up for automated code reviews on this repo. Configure here.

@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented May 8, 2026

@cursor review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 26389 bytes
Compressed size limit: 29000
Uncompressed size: 129320 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 31979 bytes
Compressed size limit: 34000
Uncompressed size: 114243 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 179654 bytes
Compressed size limit: 200000
Uncompressed size: 831422 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 38768 bytes
Compressed size limit: 39000
Uncompressed size: 212567 bytes

@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented May 8, 2026

@cursor review

cursor[bot]

This comment was marked as resolved.

@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented May 8, 2026

@cursor review

@joker23 joker23 force-pushed the skz/sdk-1997/client-test-data-plugin branch from df6d8ed to 637feac Compare May 8, 2026 16:18
@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented May 8, 2026

@cursor review

cursor[bot]

This comment was marked as resolved.

@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented May 8, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b9eed76. Configure here.

@joker23 joker23 marked this pull request as ready for review May 8, 2026 16:58
@joker23 joker23 requested a review from a team as a code owner May 8, 2026 16:58
devin-ai-integration[bot]

This comment was marked as resolved.

td.setBool('new-ui', false).setString('greeting', 'Welcome');
```

### Why these options matter
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a strange heading.

- **`streaming: false`** -- prevents the SDK from auto-starting a streaming connection when a `change` listener is registered. Without this, the React SDK provider (and any other code that registers `change` listeners) will trigger a real network call to `clientstream.launchdarkly.com`.
- **`bootstrap: {}` (passed to `start()`)** -- gives the SDK an empty initial flag set so it does not block on a network identify call. The plugin's overrides are applied immediately afterward.

If you forget any of these, the SDK may attempt to fetch flags from LaunchDarkly during initialization and produce real network traffic, console errors, or stray evaluation events.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would lean toward having a helper function in the test data package?

const client = createTestClient({kind: 'user', key: 'tester'});

Maybe optionally allowing options, but making it clear that the specific settings are overwritten.

const client = createTestClient({kind: 'user', key: 'tester'}, {/* maybe custom options*/}

Certainly we would support the version you demonstrate as well, but I think most people just need a client.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I think you were trying to make one of these work for all client-side? Makes me a little uncomfortable not having leaf-nodes where we can customize and change decisions if we need to.

Copy link
Copy Markdown
Contributor Author

@joker23 joker23 Jun 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think providing a wrapped client creation function could help... I think we should still export a more manual way of getting this functionality.

The use case I am thinking about is developers using this plugin for their mocked LD clients. I think that would be a cleaner mock client implementation.

With that said, I think if we provide a per sdk wrapper, then we can make the "manual" path a bit more low level... I'll do a pass on the README now

* `setOverride` unless this is a no-op primitive write (same key, same
* primitive value as before). Object/array writes always fire.
*/
private _set(key: string, value: LDFlagValue): this {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this same value check stuff and duplication of the values? There are ways for a real connection to trigger updates even though these fields didn't change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I will remove this check...

@joker23 joker23 force-pushed the skz/sdk-1997/client-test-data-plugin branch from b9eed76 to c2fa0f6 Compare June 2, 2026 18:41
@joker23 joker23 merged commit 891ffe2 into main Jun 2, 2026
45 checks passed
@joker23 joker23 deleted the skz/sdk-1997/client-test-data-plugin branch June 2, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants