AdrienTorris / awesome-blazor

Resources for Blazor, a .NET web framework using C#/Razor and HTML that runs in the browser with WebAssembly.
Creative Commons Zero v1.0 Universal
8.85k stars 981 forks source link

Testing Blazor Sites #247

Closed SuperDaveOsbourne closed 3 years ago

SuperDaveOsbourne commented 4 years ago

Is there any plan for how Blazor sites will be tested? I see Playwright https://github.com/microsoft/playwright as the closest thing so far. Not sure how well web assembly will work with sites going forward?

chrissainty commented 4 years ago

Steve Sanderson has released a prototype testing library which you can find here. There is also an excellent testing library by Egil Hansen which builds on the features of Steves library but adds much more.

Ultimately, most UI testing frameworks will work with Blazor as they are just looking at outputted HTML (Selenium for example). The libraries above try to offer a bit more and a better way.

SuperDaveOsbourne commented 4 years ago

How will the screen scraping approach work if I want to test remotely? What are the implications if any?

chrissainty commented 4 years ago

Are you talking about testing a render of the UI? If so, any way you’ve done this with other frameworks should work wit Blazor

AdrienTorris commented 4 years ago

There is a great video from the last .NET Conf "Focus on Blazor" by Egil Hansen about testing Blazor components: https://channel9.msdn.com/Events/dotnetConf/Focus-on-Blazor/Testing-Blazor-Components You probably should watch it.

ray440 commented 4 years ago

You can try IcuBlazor: http://icublazor.com/. Like Playwright, you can automate your UI, take snapshots and pixel-diff them. All with lovely blazor code.

AdrienTorris commented 3 years ago

Thank you all for the answers, I close this issue.