Skip to content

Commit b68c976

Browse files
authored
Merge pull request #97 from ComponentDriven/next
0.1.9 release
2 parents 4251fb2 + 03a4125 commit b68c976

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/story.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ export type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args>
262262
type Awaitable<T> = T | PromiseLike<T>;
263263
export type CleanupCallback = () => Awaitable<unknown>;
264264

265+
export type BeforeAll = () => Awaitable<CleanupCallback | void>;
266+
265267
export type BeforeEach<TRenderer extends Renderer = Renderer, TArgs = Args> = (
266268
context: StoryContext<TRenderer, TArgs>
267269
) => Awaitable<CleanupCallback | void>;
@@ -390,6 +392,20 @@ export type ProjectAnnotations<
390392
> = BaseAnnotations<TRenderer, TArgs> & {
391393
argsEnhancers?: ArgsEnhancer<TRenderer, Args>[];
392394
argTypesEnhancers?: ArgTypesEnhancer<TRenderer, Args>[];
395+
396+
/**
397+
* 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).
398+
* The function may be synchronous or asynchronous, and may return a cleanup function which may also be synchronous or asynchronous.
399+
* The cleanup function is not guaranteed to run (e.g. when the browser closes), but runs when configuration changes or when reinitializing.
400+
* This hook may only be defined globally (i.e. not on component or story level).
401+
* When multiple hooks are specified, they are to be executed sequentially (and awaited) in the following order:
402+
* - Addon hooks (in order of addons array in e.g. .storybook/main.js)
403+
* - Annotation hooks (in order of previewAnnotations array in e.g. .storybook/main.js)
404+
* - Preview hook (via e.g. .storybook/preview.js)
405+
* Cleanup functions are executed sequentially in reverse order of initialization.
406+
*/
407+
beforeAll?: BeforeAll;
408+
393409
/**
394410
* @deprecated Project `globals` renamed to `initiaGlobals`
395411
*/

0 commit comments

Comments
 (0)