From 2ccc94b4bdf0359f1888d59c26f9835c8062032c Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Mon, 24 Jun 2024 13:21:29 +0200 Subject: [PATCH] Extend explanation of beforeAll hook --- src/story.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/story.ts b/src/story.ts index 5bc0e52..c4f173b 100644 --- a/src/story.ts +++ b/src/story.ts @@ -394,8 +394,15 @@ export type ProjectAnnotations< argTypesEnhancers?: ArgTypesEnhancer[]; /** - * Function to be called once, before rendering any story. When the function is async, it will be awaited. - * A cleanup function may be returned. This function may only be defined globally. + * Lifecycle hook which runs once, before any loaders, decorators or stories, and may rerun when configuration changes or when reinitializing (e.g. between test runs). + * The function may be synchronous or asynchronous, and may return a cleanup function which may also be synchronous or asynchronous. + * The cleanup function is not guaranteed to run (e.g. when the browser closes), but runs when configuration changes or when reinitializing. + * This hook may only be defined globally (i.e. not on component or story level). + * When multiple hooks are specified, they are to be executed sequentially (and awaited) in the following order: + * - Addon hooks (in order of addons array in e.g. .storybook/main.js) + * - Annotation hooks (in order of previewAnnotations array in e.g. .storybook/main.js) + * - Preview hook (via e.g. .storybook/preview.js) + * Cleanup functions are executed sequentially in reverse order of initialization. */ beforeAll?: BeforeAll;