I've a problem writing test for a page which is using Microsoft.AspNetCore.Components.Web.Extensions.Head.Title component.
No issues when I remove the Title. The page looks like this:
@page "/sample"
<Title Value="Sample"></Title>
<div>@Text</div>
@code {
[Parameter]
public string Text { get; set; } = string.Empty;
}
And here is the test:
using Bunit;
using Bunit.TestDoubles;
using Xunit;
namespace Tests
{
public class SampleTests
{
private TestContext _context;
public SampleTests()
{
_context = new TestContext();
_context.Services.AddMockJSRuntime();
}
[Fact]
public void PageShouldRender()
{
var html = _context.RenderComponent<Sample>(parameters =>
parameters.Add(p => p.Text, "Sample"));
}
}
}
Error:
{"Value cannot be null. (Parameter 'jsObjectReference')"}
