Back to Storybook

Shadow Dom Testing Library In Story

docs/_snippets/shadow-dom-testing-library-in-story.md

10.3.61.3 KB
Original Source
ts
export const ShadowDOMExample: Story = {
  async play({ canvas }) {
    // ๐Ÿ‘‡ Will find an element even if it's within a shadow root
    const button = await canvas.findByShadowRole('button', { name: /Reset/i });
  },
};
js
export const ShadowDOMExample = {
  async play({ canvas }) {
    // ๐Ÿ‘‡ Will find an element even if it's within a shadow root
    const button = await canvas.findByShadowRole('button', { name: /Reset/i });
  },
};
js
export const ShadowDOMExample = meta.story({
  async play({ canvas }) {
    // ๐Ÿ‘‡ Will find an element even if it's within a shadow root
    const button = await canvas.findByShadowRole('button', { name: /Reset/i });
  },
});
ts
export const ShadowDOMExample = meta.story({
  async play({ canvas }) {
    // ๐Ÿ‘‡ Will find an element even if it's within a shadow root
    const button = await canvas.findByShadowRole('button', { name: /Reset/i });
  },
});