Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

launchdarkly-js-test-helpers

launchdarkly52.9kApache-2.02.2.0TypeScript support: included

LaunchDarkly JavaScript test utilities

launchdarkly, testing

readme

LaunchDarkly JavaScript Test Helpers

Circle CI

This package centralizes some test support code that is used by LaunchDarkly's JavaScript-based SDKs (browser, Node, Electron, etc.) and that may be useful in other JS projects. It can be used to test any kind of JavaScript code as long as the tests themselves are run in Node (version 6 or higher).

While this code may be useful in other projects, it is primarily geared toward LaunchDarkly's own development needs and is not meant to provide a large general-purpose framework. It is meant for unit test code and should not be used as a runtime dependency.

The module is implemented in TypeScript, but can be used without TypeScript. See the API documentation for a description of the functions, parameters, and types in TypeScript syntax.

Usage

In TypeScript or ES6 code:

import { TestHttpServer, promisify } from "launchdarkly-js-test-helpers";

In regular Node.js code:

const { TestHttpServer, promisify } = require("launchdarkly-js-test-helpers");

Build helpers

The scripts directory contains tools that can be helpful in CI; see scripts/README.md.

Contributing

We encourage pull requests and other contributions from the community. Check out our contributing guidelines for instructions on how to contribute to this SDK.

About LaunchDarkly

  • LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
    • Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
    • Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
    • Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
    • Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
  • LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out our documentation for a complete list.
  • Explore LaunchDarkly

changelog

Change log

All notable changes to the package will be documented in this file. This project adheres to Semantic Versioning.

[2.1.1] - 2021-09-22

The 2.1.0 release was damaged and did not contain source files. 2.1.1 is a rerelease containing the same functionality.

[2.1.0] - 2021-09-22

Added:

  • You can optionally specify a port for an HTTP server to listen on, instead of letting it automatically pick a port.

Fixed:

  • TestHttpHandlers.sseStream was incorrectly writing event: undefined if you omitted the event type, instead of completely omitting that line.

[2.0.0] - 2021-08-23

Changed:

  • Minimum Node version is now 12.
  • Updated many dependencies to newer versions.

[1.3.1] - 2021-07-16

Fixed:

  • Fixed the implementation of AsyncMutex which was not behaving as intended when more than two tasks contended for a lock.

[1.3.0] - 2021-07-07

Added:

  • AsyncMutex, a simple async lock implementation for test serialization.

[1.2.1] - 2021-06-09

Fixed:

  • When generating a self-signed certificate for TLS testing, use a key size of 2048 bits (rather than 1024, the default used by the selfsigned module) for maximum cross-platform compatibility.

[1.2.0] - 2020-04-23

Added:

  • Methods in TestHttpServer for creating simple proxy servers.

[1.1.0] - 2019-12-03

Added:

  • TestHttpServers, containing the same static factory methods that are in TestHttpServer. This is a workaround for a transpiler problem that can prevent imports from working correctly for classes that have a constructor as well as static methods.

[1.0.0] - 2019-11-26

Initial release.