-
I've a problem writing test for a page which is using @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: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @dawidr Please provide the following info:
|
Beta Was this translation helpful? Give feedback.
-
@egil After your comment, I noticed that I've outdated bUnit. So right now I'm on bUnit 1.0.0-preview-01 and .Net Core 5.0.1. The error is different right now:
To put more light on the |
Beta Was this translation helpful? Give feedback.
-
Try settting |
Beta Was this translation helpful? Give feedback.
Try settting
JSRuntimeMode
toLoose
, see here for more details: https://bunit.egilhansen.com/docs/test-doubles/emulating-ijsruntime.html