import type { ReactRenderer, Args } from '@storybook/react'; import type { ComponentAnnotations, ProjectAnnotations } from '@storybook/types'; import type { StoriesWithPartialProps, StoryFile, TestingStory, TestingStoryPlayContext } from './types'; export type { StoriesWithPartialProps, StoryFile } from './types'; /** Function that sets the globalConfig of your storybook. The global config is the preview module of your .storybook folder. * * It should be run a single time, so that your global config (e.g. decorators) is applied to your stories when using `composeStories` or `composeStory`. * * Example: *```jsx * // setup.js (for jest) * import { setProjectAnnotations } from '@storybook/testing-react'; * import * as projectAnnotations from './.storybook/preview'; * * setProjectAnnotations(projectAnnotations); *``` * * @param projectAnnotations - e.g. (import * as projectAnnotations from '../.storybook/preview') */ export declare function setProjectAnnotations(projectAnnotations: ProjectAnnotations | ProjectAnnotations[]): void; /** * @deprecated Use setProjectAnnotations instead */ export declare function setGlobalConfig(projectAnnotations: ProjectAnnotations | ProjectAnnotations[]): void; /** * Function that will receive a story along with meta (e.g. a default export from a .stories file) * and optionally a globalConfig e.g. (import * from '../.storybook/preview) * and will return a composed component that has all args/parameters/decorators/etc combined and applied to it. * * * It's very useful for reusing a story in scenarios outside of Storybook like unit testing. * * Example: *```jsx * import { render } from '@testing-library/react'; * import { composeStory } from '@storybook/testing-react'; * import Meta, { Primary as PrimaryStory } from './Button.stories'; * * const Primary = composeStory(PrimaryStory, Meta); * * test('renders primary button with Hello World', () => { * const { getByText } = render(Hello world); * expect(getByText(/Hello world/i)).not.toBeNull(); * }); *``` * * @param story * @param meta - e.g. (import Meta from './Button.stories') * @param [globalConfig] - e.g. (import * as globalConfig from '../.storybook/preview') this can be applied automatically if you use `setGlobalConfig` in your setup files. */ export declare function composeStory(story: TestingStory, meta: ComponentAnnotations, globalConfig?: ProjectAnnotations): { (extraArgs: Partial): import("@storybook/react/dist/types-0a347bb9").S; storyName: string | undefined; args: GenericArgs; play: ({ ...extraContext }: TestingStoryPlayContext) => void | Promise; decorators: (import("@storybook/types").DecoratorFunction | import("@storybook/types").DecoratorFunction)[]; parameters: import("@storybook/types").Parameters; }; /** * Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`) * and optionally a globalConfig (e.g. `import * from '../.storybook/preview`) * and will return an object containing all the stories passed, but now as a composed component that has all args/parameters/decorators/etc combined and applied to it. * * * It's very useful for reusing stories in scenarios outside of Storybook like unit testing. * * Example: *```jsx * import { render } from '@testing-library/react'; * import { composeStories } from '@storybook/testing-react'; * import * as stories from './Button.stories'; * * const { Primary, Secondary } = composeStories(stories); * * test('renders primary button with Hello World', () => { * const { getByText } = render(Hello world); * expect(getByText(/Hello world/i)).not.toBeNull(); * }); *``` * * @param storiesImport - e.g. (import * as stories from './Button.stories') * @param [globalConfig] - e.g. (import * as globalConfig from '../.storybook/preview') this can be applied automatically if you use `setGlobalConfig` in your setup files. */ export declare function composeStories(storiesImport: TModule, globalConfig?: ProjectAnnotations): Pick, Exclude>;