You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To address the issue of annotations.beforeAll being potentially undefined, update the type definition in the setProjectAnnotations function to ensure beforeAll is always defined.
Update Type Definition:
Modify the return type of setProjectAnnotations in /code/renderers/react/src/portable-stories.tsx and /code/renderers/vue3/src/portable-stories.ts to ensure beforeAll is always defined.
Ensure tests in /code/core/src/preview-api/modules/store/csf/portable-stories.test.ts reflect the new type definition.
it('should return composed beforeAll as part of project annotations',async()=>{constafter=vi.fn();constbefore=vi.fn((n)=>()=>after(n));constfinalAnnotations=setProjectAnnotations([{beforeAll: ()=>before(1)},{beforeAll: ()=>before(2)},{beforeAll: ()=>before(3)},]);constcleanup=awaitfinalAnnotations.beforeAll?.();expect(before.mock.calls).toEqual([[1],[2],[3]]);awaitcleanup?.();expect(after.mock.calls).toEqual([[3],[2],[1]]);});
Describe the bug
Applying the following example code in a setupTests.ts file to setup project annotations for vitest:
annotations.beforeAll
is potentially undefined, although it is always a function, even if the user doesn’t definebeforeAll
.We should fix the type returned by
setProjectAnnotations
to always setbeforeAll
as required.The text was updated successfully, but these errors were encountered: