microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.35k stars 228 forks source link

[Feature]: Blazor component testing #2944

Open sand4rt opened 3 weeks ago

sand4rt commented 3 weeks ago

🚀 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?

mxschmitt commented 3 weeks ago

Let's see if there is any interest for it.