Skip to content

Beta 5 - winter cleaning

Choose a tag to compare

@egil egil released this 23 Jan 09:00

The beta 5 release of the library is ready to go. This beta 5 comes with a few cleanups of the API, better support for adding services to the TestServiceProvider, support for async test and setup methods in snapshot and razor- based tests, and other small changes.

Since the last release, the .NET Conf - Focus on Blazor event happened, and this library was featured in a session on "Testing Blazor Components" I was invited to do. So if you are now to the library, you can get a 35 minute intro right that way. All sessions are available on YouTube, if you missed it.

Changes in beta 5:

  • Breaking change: In ITextContext, the TestHtmlParser HtmlParser { get; } property has been removed and replaced with the method INodeList CreateNodes(string markup);
  • Breaking change: The GetNodes() and GetMarkup() methods to Nodes and Markup properties in IRenderedFragment.
  • Beaking change: TestServiceProvider, exposed through the Services property in the test contexts, is now a true IServiceCollection. This unfortunately means you have to update all calls to AddService to AddSingleton (issue #39).
    NOTE: You also need to add an import to Microsoft.Extensions.DependencyInjection to make the methods AddSingleton, AddTransient, etc. available in your tests.
  • Added Async methods setup and test methods to <Fixture/>.
    Big thanks to @duracellko for the contribution of this.
  • Added a IJsRuntime placeholder to the services collection if none has been added by the developer (issue #26).
    Big thanks to @Siphonophora for the contribution of this.
  • Added SetupVoid and SetVoidResult capabilities to the built in JsRuntime mock (issue #30).
  • Moved JsRuntime Mock into its own namespace: Egil.RazorComponents.Testing.Mocking.JSInterop.

Ressources:

You can get the latest version from NuGet:

NuGet data Type Link
Nuget Library https://www.nuget.org/packages/Razor.Components.Testing.Library/
Nuget Template https://www.nuget.org/packages/Razor.Components.Testing.Library.Template/

First contributions

A big thank you to the first two contributors, Rastislav Novotný (@duracellko) and Michael J Conrad (@Siphonophora). I hope to see more in the future from you guys, as well as others.

Also thank you to those who have participated in discussion in on issues board, and provided feedback on Twitter and Gitter.

Upcoming releases

The next release will focus on making the library independent of xUnit, such that you as a developer can choose to use another library. Built-in support for e.g. nUnit might not be in the next release, but it will make it much easier to use MSTest or nUnit.

Thanks, Egil.