Skip to content

[Bug]: Type for beforeAll is possibly undefined when used in portable stories #28513

Closed

Description

Describe the bug

Applying the following example code in a setupTests.ts file to setup project annotations for vitest:

import { beforeAll } from "vitest";
import { setProjectAnnotations } from "@storybook/react";
import { render as testingLibraryRender } from "@testing-library/react";
import * as storybookAnnotations from "./.storybook/preview";

const annotations = setProjectAnnotations([
  storybookAnnotations,
  { testingLibraryRender },
]);

// ERROR
beforeAll(annotations.beforeAll);

annotations.beforeAll is potentially undefined, although it is always a function, even if the user doesn’t define beforeAll.

We should fix the type returned by setProjectAnnotations to always set beforeAll as required.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions