• Public
  • Public/Protected
  • All

This module contains tools for connecting the LaunchDarkly client to other software, or to test fixtures.



  • Creates an object that allows you to use local files as a source of feature flag state, instead of connecting to LaunchDarkly. This would typically be used in a test environment.

    For more information about this feature, see the SDK features guide.

    To use this component, call FileDataSource(options) and store the result in the updateProcessor property of your LaunchDarkly client configuration:

    const { FileDataSource } = require('launchdarkly-node-server-sdk/integrations');

    const dataSource = FileDataSource({ paths: [ myFilePath ] });
    const config = { updateProcessor: dataSource };

    This will cause the client not to connect to LaunchDarkly to get feature flags, and use the file data instead.

    The client may still make network connections to send analytics events, unless you have disabled this in your configuration by setting LDOptions.sendEvents to false.

    The supported file formats are as follows:

    • JSON files in the format described in the SDK features guide are always supported.
    • The SDK can also read YAML files with an equivalent schema, if you explicitly install the yaml package in your application. This package is not installed by default, to avoid adding to the size of the SDK bundle for this rarely-used feature. The SDK is compatible with any version of the package that supports calling yaml.parse(string) with no custom options.


    Returns object

    An object to put in the updateProcessor property for LDOptions.

  • A mechanism for providing dynamically updatable feature flag state in a simplified form to an SDK client in test scenarios.

    This function constructs a new TestData object. See TestData for usage details.

    const { TestData } = require('launchdarkly-node-server-sdk/interfaces');

    const td = TestData();
    const client = new LDClient(sdkKey, { updateProcessor: td });

    // flags can be updated at any time:
    .variationForContext("user", "some-user-key", true)

    Returns "launchdarkly-node-server-sdk/integrations".TestData

Generated using TypeDoc