Skip to content

Svelte 5: Programmatically creating snippets #9980

Closed
@andersekdahl

Description

@andersekdahl

Describe the problem

I've had the need to create snippets (specifically for the children prop) both in unit tests as well as in Storybook. My current workaround has been to create a new component which passes what I need as children to the component I want to test. But that creates indirection since I need to place that in a separate file.

Describe the proposed solution

It would be great to have some built-in API to define a snippet function without having to have a .svelte file. This would simplify testing components with @testing-library/svelte as well as passing args as snippet props in Storybook.

Alternatives considered

As mentioned I've been defining new components in new files that pass the snippets I want, but I don't think that's a good long-term solution.

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions