Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 65x 65x 65x 65x 12x 12x 77x 77x 12x 65x 12x | import type {StoryObj, Meta} from '@storybook/web-components';
import {it} from 'vitest';
async function playStory( story: StoryObj, meta: Meta )
{
document.body.innerHTML = meta.render(story.args);
await new Promise( (resolve) => setTimeout(async ()=>
{
await story.play({canvasElement: document.body.lastElementChild});
resolve(0);
},0))
}
export async function testStoryBook<TProps>( mod: Record<string, StoryObj>, meta: Meta )
{
const {describe, it } = await import('vitest');
function playStories( mod: Record<string, StoryObj>, meta: Meta )
{
Object.keys(mod).map(name=>
{
const story = mod[name];
if( !story.play )
return;
it( name, async()=>playStory(story,meta));
})
}
describe( meta.title, async () => playStories(mod, meta) )
}
|