initializeFireflyForStorybook

Create a runtime instance tailored for Storybook and optionally register local modules.

Reference

const runtime = initializeFireflyForStorybook(options?: { localModules?, environmentVariables?, featureFlags?, launchDarklyClient?, loggers?, useMsw? })

Parameters

  • options: An optional object literal of options:
    • localModules: An optional array of ModuleRegisterFunction.
    • environmentVariables: An optional object of environment variables.
    • featureFlags: An optional Map instance of feature flags.
    • launchDarklyClient: An optional LaunchDarkly client to override the default client.
    • loggers: An optional array of logger instances.
    • useMsw: An optional boolean value indicating whether or not to create the runtime with Mock Service Work (MSW) support. Default is true.
    • additionalPlugins: An optional array with additional plugins to be registered with the runtime.

Returns

A StorybookRuntime instance.

Usage

Initialize with local modules

import { initializeFireflyForStorybook } from "@squide/firefly-storybook";

const runtime = initializeFireflyForStorybook({
    localModules: [...]
});

Initialize with environment variables

import { initializeFireflyForStorybook } from "@squide/firefly-storybook";

const runtime = initializeFireflyForStorybook({
    environmentVariables: {
        "foo": "bar"
    }
});

Initialize with feature flags

import { initializeFireflyForStorybook } from "@squide/firefly-storybook";

const runtime = initializeFireflyForStorybook({
    featureFlags: {
        "show-characters": true
    }
});

Initialize with a LaunchDarkly client

import { initializeFireflyForStorybook } from "@squide/firefly-storybook";
import { InMemoryLaunchDarklyClient } from "@squide/firefly";

const launchDarklyClient = new InMemoryLaunchDarklyClient(featureFlags);

const runtime = initializeFireflyForStorybook({
    featureFlags: {
        "show-characters": true
    },
    launchDarklyClient
});

Initialize without MSW support

import { initializeFireflyForStorybook } from "@squide/firefly-storybook";

const runtime = initializeFireflyForStorybook({
    useMsw: false
});

Initialize with i18next

import { initializeFireflyForStorybook } from "@squide/firefly-storybook";
import { i18nextPlugin } from "@squide/i18next";

const runtime = initializeFireflyForStorybook({
    additionalPlugins: [x => new i18nextPlugin(x, ["en-US", "fr-CA"], "en-US", "language")]
});