Skip to content

Commit 9502229

Browse files
committed
test: add better assert messages and increase snapshot timeout
1 parent 99f6882 commit 9502229

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

.storybook/preview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ const preview = definePreview({
8181
export async function hasFinishedLoading({ step, canvas }: Pick<Parameters<NonNullable<StoryObj['play']>>[0], 'step' | 'canvas'>) {
8282
await step('Finished Loading', async () => {
8383
await waitFor(async () => {
84-
await expect(canvas.queryAllByRole('progressbar')).toHaveLength(0);
85-
await expect(canvas.queryAllByText(/loading\.\.\./i)).toHaveLength(0);
84+
await expect(canvas.queryAllByRole('progressbar'), 'has no progress bars').toHaveLength(0);
85+
await expect(canvas.queryAllByText(/loading\.\.\./i), 'has no loading messages').toHaveLength(0);
8686
}, { timeout: 10000 });
8787
});
8888
}

.storybook/tests.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { expect, test } from 'vitest';
33

44
export function createSnapshotTest(testName: string, story: { run: () => Promise<void>; composed: { parameters: { snapshot: boolean; }}}) {
55
if (!story.composed.parameters?.snapshot) return;
6-
return test(testName, async () => {
6+
return test(testName, { timeout: 30000 }, async () => {
77
await story.run();
88
// make sure done loading
99
await waitFor(() => {
10-
expect(document.querySelectorAll('.MuiTouchRipple-childLeaving')).toHaveLength(0);
10+
expect(document.querySelectorAll('.MuiTouchRipple-childLeaving'), 'has no button ripples in progress').toHaveLength(0);
1111
});
1212
const children = Array.from(document.body.childNodes).filter((node) => (node.nodeName !== '#text' || node.textContent?.trim() != '') && !(node as Element).classList?.contains('sb-wrapper'));
1313
const child = children.length <= 1 ? children[0] : children;

0 commit comments

Comments
 (0)