chore: init @launchdarkly/client-testing-plugin#1373
Conversation
|
@cursor review |
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/browser size report |
|
@launchdarkly/js-client-sdk-common size report |
|
@cursor review |
|
@cursor review |
df6d8ed to
637feac
Compare
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
✅ 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.
| td.setBool('new-ui', false).setString('greeting', 'Welcome'); | ||
| ``` | ||
|
|
||
| ### Why these options matter |
| - **`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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Good point, I will remove this check...
b9eed76 to
c2fa0f6
Compare
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 exposesTestDataas an SDK plugin for tests and local dev. It drives the existingregisterDebug/LDDebugOverridepath so flag values can be seeded, updated (withchange: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.jsonworkspaces andtsconfig.jsonreferences;.gitignoreswaps.claude/stacksfor.claude/tmp.Reviewed by Cursor Bugbot for commit c2fa0f6. Bugbot is set up for automated code reviews on this repo. Configure here.