Skip to content

[Feature]: Blazor component testing #2944

Open
@sand4rt

Description

@sand4rt

🚀 Feature Request

Wondering if you've considered adding Playwright component testing for Blazor: https://learn.microsoft.com/en-us/aspnet/core/blazor/test?view=aspnetcore-8.0#test-components-with-bunit?

Example

<button @onclick="HandleClick">@title</button>

@code {
    [Parameter]
    public string title { get; set; } = "";
}
@code
{
    [Fact]
    public async Task HasTitle()
    { 
        var Component = await mount(@<Button title="Hello" />);
        await Expect(Component).ToHaveText("Hello");
    }
}

or

public class Button
{
    [Fact]
    public void HasTitle()
    {
        var Component = mount<Button>({ props = { title = "hello" });
        await Expect(Component).ToHaveText("Hello");
    }
}

Motivation

I'm not a Blazor user, but i think it might be interesting for the people who do?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions