Private
_currentPrivate
_currentPrivate
_dataPrivate
_flagCreates or copies a TestDataFlagBuilder for building a test flag configuration.
If the flag key has already been defined in this TestData
instance,
then the builder starts with the same configuration that was last
provided for this flag.
Otherwise, it starts with a new default configuration in which the flag
has true
and false
variations, is true
for all users when targeting
is turned on and false
otherwise, and currently has targeting turned on.
You can change any of those properties and provide more complex behavior
using the TestDataFlagBuilder
methods.
Once you have set the desired configuration, pass the builder to TestData.update.
the flag key
a flag configuration builder
Get a factory for update processors that will be attached to this TestData instance.
An update processor factory.
Get a factory for update processors that will be attached to this TestData instance.
Optional
errorHandler: ((e) => void)Optional
An update processor factory.
Updates the test data with the specified flag configuration.
This has the same effect as if a flag were added or modified in the
LaunchDarkly dashboard. It immediately propagates the flag changes to
any LDClient
instance(s) that you have already configured to use
this TestData
. If no LDClient
has been started yet, it simply adds
this flag to the test data which will be provided to any LDClient
that you subsequently configure.
Any subsequent changes to this TestDataFlagBuilder
instance do not affect
the test data unless you call update
again.
a flag configuration builder
a promise that will resolve when the feature stores are updated
Copies a full feature flag data model object into the test data.
It immediately propagates the flag change to any LDClient
instance(s) that you have already
configured to use this TestData
. If no LDClient
has been started yet, it simply adds this
flag to the test data which will be provided to any LDClient that you subsequently configure.
Use this method if you need to use advanced flag configuration properties that are not supported by the simplified TestDataFlagBuilder API. Otherwise it is recommended to use the regular flag/update mechanism to avoid dependencies on details of the data model.
You cannot make incremental changes with flag/update to a flag that has been added in this way; you can only replace it with an entirely new flag configuration.
a promise that will resolve when the feature stores are updated
Copies a full segment data model object into the test data.
It immediately propagates the change to any LDClient
instance(s) that you have already
configured to use this TestData
. If no LDClient
has been started yet, it simply adds
this segment to the test data which will be provided to any LDClient that you subsequently
configure.
This method is currently the only way to inject segment data, since there is no builder API for segments. It is mainly intended for the SDK's own tests of segment functionality, since application tests that need to produce a desired evaluation state could do so more easily by just setting flag values.
a promise that will resolve when the feature stores are updated
Generated using TypeDoc
A mechanism for providing dynamically updatable feature flag state in a simplified form to an SDK client in test scenarios.
Unlike
FileData
, this mechanism does not use any external resources. It provides only the data that the application has put into it using the TestData.update method.The above example uses a simple boolean flag, but more complex configurations are possible using the methods of the TestDataFlagBuilder that is returned by TestData.flag. TestDataFlagBuilder supports many of the ways a flag can be configured on the LaunchDarkly dashboard, but does not currently support
If the same
TestData
instance is used to configure multipleLDClient
instances, any changes made to the data will propagate to all of theLDClient
s.