This package provides a collection of JavaScript test utilities primarily developed for internal use by LaunchDarkly's JavaScript-based SDKs (browser, Node, Electron). It is designed to support unit testing environments running on Node.js (version 12 or higher since v2.0.0), offering features like HTTP server mocks, HTTP handler utilities, async mutexes, and async helper functions for managing test expectations. While useful for general JavaScript testing, its design is tailored to LaunchDarkly's specific development needs rather than being a broad, general-purpose testing framework. The current stable version is 2.2.0. Releases appear to be ad-hoc, following an 'as-needed' cadence, with the latest significant update in April 2022. The library is implemented in TypeScript and ships with type definitions.
npm install launchdarkly-js-test-helpersVerified import paths — ran on the pinned version, not inferred.
Sets up a basic `TestHttpServer`, adds a handler to return a JSON response, and then makes a request to it to verify functionality.
Upgrade your Node.js environment to version 12 or newer to ensure compatibility.
No direct fix needed unless custom certificate handling relies on older `selfsigned` behavior; otherwise, ensure your test environment handles standard certificate generation.
Do not use version 2.1.0. If you encounter issues, upgrade to 2.1.1 or any later version.
If experiencing issues with static method imports from `TestHttpServer`, try importing `TestHttpServers` instead: `import { TestHttpServers } from 'launchdarkly-js-test-helpers';`Ensure Node.js v12 or higher is installed and run `npm install` to refresh dependencies. Check `npm ls selfsigned` to verify the package is installed.
Ensure you are importing the `TestHttpServer` class correctly for instantiation: `import { TestHttpServer } from 'launchdarkly-js-test-helpers'; new TestHttpServer();`