mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 02:01:48 +08:00
35 lines
1.1 KiB
Plaintext
35 lines
1.1 KiB
Plaintext
```ts
|
|
// MyComponent.stories.ts
|
|
|
|
import type { Meta, StoryObj } from '@storybook/angular';
|
|
|
|
import { userEvent, within } from '@storybook/testing-library';
|
|
|
|
import { MyComponent } from './MyComponent.component';
|
|
|
|
const meta: Meta<MyComponent> = {
|
|
/* 👇 The title prop is optional.
|
|
* See https://storybook.js.org/docs/7.0/angular/configure/overview#configure-story-loading
|
|
* to learn how to generate automatic titles
|
|
*/
|
|
title: 'QueryMethods',
|
|
component: MyComponent,
|
|
};
|
|
|
|
export default meta;
|
|
type Story = StoryObj<MyComponent>;
|
|
|
|
/*
|
|
* See https://storybook.js.org/docs/7.0/angular/writing-stories/play-function#working-with-the-canvas
|
|
* to learn more about using the canvasElement to query the DOM
|
|
*/
|
|
export const ExampleWithRole: Story = {
|
|
play: async ({ canvasElement }) => {
|
|
const canvas = within(canvasElement);
|
|
|
|
// See https://storybook.js.org/docs/7.0/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
|
|
await userEvent.click(canvas.getByRole('button', { name: / button label/i }));
|
|
},
|
|
};
|
|
```
|